I got a little confused about Python raw string. I know that if we use raw string, then it will treat '\' as a normal backslash (ex. r'\n' would be \ and n). However, I was wondering what if I want to match a new line character in raw string. I tried r'\\n', but it didn’t work.
Anybody has some good idea about this?
In a regular expression, you need to specify that you’re in multiline mode:
Notice that
retranslates the\n(raw string) into newline. As you indicated in your comments, you don’t actually needre.Mfor it to match, but it does help with matching$and^more intuitively: