I came up with the below which finds a string in a row and copies that row to a new file. I want to replace Foo23 with something more dynamic (i.e. [0-9], etc.), but I cannot get this, or variables or regex, to work. It doesn't fail, but I also get no results. Help? Thanks.
with open('C:/path/to/file/input.csv') as f:
with open('C:/path/to/file/output.csv', "w") as f1:
for line in f:
if "Foo23" in line:
f1.write(line)
r"[A-Za-z][A-Za-z][A-Za-z]\d\d"...but I cannot get this, or variables or regex, to work.- please read minimal reproducible example. Show us what you are trying to do that doesn't work - include an example input string(s).r"[A-Za-z][A-Za-z][A-Za-z]\d\d"Tryimport reand then testif re.search(r"[A-Za-z][A-Za-z][A-Za-z]\d\d", line):or regexin my initial question, I meant that I did tryimport reetc. etc.