0

I am trying to use two variables in a re.compile as well as making it a variable. I might be doing something completely wrong but I am not knowledgeable enough to know what.

Find = re.compile( "%s" str(variable1).zfill(2), \.\d\d\., "%s" % variable2)

Now I know this might be completely wrong, but this is the best I know with my current knowledge, so It would be amazing if someone could explain to me what I am doing wrong.

  • Use f-strings, `find = re.compile(rf"{variable1.zfill(2)}\.\d{{2}}\.{variable2}")`. Inside f-strings, literal `{` and `}` must be doubled. – Wiktor Stribiżew May 11 '22 at 14:55

0 Answers0