New on stackoverflow.
compiled = re.compile(r'\\\d\\\d')
compiled.match("\3\3")
as of my understanding first two backslash will match one backslash in searched string and \d
will match one number. why not this string able to match regex?
CodePudding user response:
you should save the matched results in a variable: matched = compiled.match("\3\3")
. Please refer to this article
CodePudding user response:
Use raw string to prevent "\3"
from being escaped
compiled = re.compile(r'\\\d\\\d')
compiled.match(r"\3\3")