I want to remove lines from output that contains in them one of the substrings in my "pattern_list" with python re but keep the output as one string (without those lines).
So , I looked on re library and wrote the following code:
patterns_to_remove = ["$",":",">"]
patterns = "|".join(patterns_to_remove)
extra_lines_with_patterns = re.findall('\r\n.*{} \\w*'.format(re.escape(patterns)), str(output))
for extra_line in extra_lines_with_patterns:
output = str(output).replace(extra_line, "")
return output
So if my output is :
$a$
:b:
^c^
I want the output to be:
a
b
c
but I get always None in the end , I guess I did something wrong with the re flags.