In python 3 what is the difference between re.search(r'pattern, string') and re.search(b'pattern, string)
I would be interested if someone would kindly point me to where this is documented.
CodePudding user response:
r'pattern' will look into a "raw" string, which if you have backslash, it will not interpret it as an escape character.
b'pattern' will look into a "byte" string, which is a string that is encoded.
So re.search will do the same for both, but in r'' it will analyze a raw string and in b'' it will analyze bytes.
Edit: here is the documentation on it -> Lexical Analysis
CodePudding user response:
r'pattern'
is a stringliteral while b'pattern'
is a bytesliteral