0

I am defining the following string in python:

s = '(?<=\n\d{8})(.*?)(?=\n\d{8})'

When I print it, python returns:

'(?<=\n\\d{8})(.*?)(?=\n\\d{8})'

Why it is doubling the backslash before the d?

I have also tried to make the string raw:

s = r'(?<=\n\d{8})(.*?)(?=\n\d{8})'

and in this case, python print output is:

'(?<=\\n\\d{8})(.*?)(?=\\n\\d{8})'

What is the reason behind both of these behaviours?

CEO1111
  • 37
  • 5

0 Answers0