In general, there are three options:
- Don't use the
r
prefix. That's just a convenience to avoid excessive use of double-backslashes in regexes. It isn't required. - Use
r'…'
, inside which the"
character isn't special. - Mix and match
r"…"
and''
:, e.g.pattern = '"""' + r"\s*\d\d-'\d\d'-\d\d\s*" + '"""'
In this instance, you can do both 1 and 2: single quotes and no r
prefix.