Hello, how to get line matches as a variable,
pattern_get_GB = r'(\d{1,6}GB)' for line in first_rep_out.splitlines(): if re.search(pattern_get_GB, line) GB_1.append(first_rep_GB_match) print(GB_1) Clarification: if a match is found in a line, then it needs to be written into a variable and added to the list, at the entrance we have a bash command that goes by lines, in each line I look for the data I’ve received, if found, I need to add the data to the line.
PS: I know about this option:
for line in first_rep_out.splitlines(): res = re.findall(pattern_get_GB, line) GB_1.append(res) print(GB_1) but there are blank lines in the output, how to skip them?
re.findall(pattern_get_GB, first_rep_out)without any cycles ... - MaxU