From documentation:
The solution is to use Python’s raw string notation for regular expression patterns; backslashes are not handled in any special way in a string literal prefixed with 'r'. So r"\n" is a two-character string containing '\' and 'n', while "\n" is a one-character string containing a newline. Usually patterns will be expressed in Python code using this raw string notation.
Types also match; type(u"text") == type(ur"text")
, and same goes when you remove u
. Therefore, I have to ask: what is the difference between these two? If there is no difference, why use r
at all?