Я пытаюсь извлечь несколько слов (как показано в ожидаемом выводе) из следующего файла sample.txt и поместить их в список.Я сталкиваюсь с трудностями при извлечении правильных полей.Я попробовал с моим подходом, но он не работает в большинстве случаев.Я предпочитаю делать это с помощью Python, но открыт для других языков.Любые указатели на другие подходы приветствуются.
sample.log
//*********************************************************************************
// update section
//*********************************************************************************
for (i=0; i< models; i = i+1) begin:modelgen
model_ip model_inst
(
.model_powerdown(model_powerdown),
.mcg(model_powerdown),
.lambda(_lambda[i])
);
assign fnl_verifier_lock = (tx_ready & rx_ready) ? &verifier_lock :1'b0;
native_my_ip native_my_inst
(
.tx_analogreset(tx_analogreset),
//.unused_tx_parallel_data({1536{1'b0}})
);
// END Section I :
//*********************************************************************************
resync
#(
.INIT_VALUE (1)
) inst_reset_sync
(
.clk (tx_coreclkin),
.reset (!tx_ready), // tx_digitalreset from reset
.d (1'b0),
.q (srst_tx_common )
);
ожидаемый результат
model_ip
native_my_ip
resync
моя попытка
import re
input_file = open("sample.log", "r")
result = []
for line in input_file:
# need a more generic match condition to extract expected results
match_instantiation = re.match(r'\s(.*) ([a-zA-Z_0-9]+) ([a-zA-Z_0-9]+)_inst (.*)', line)
if match_instantiation:
print match_instantiation.group(1)
result.append(match_instantiation.group(1))
else:
continue