Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (16.4k points)

Can anyone tell me what does preceding a sting literal with "r" means? I know that it's been used for building regular expressions across multiple lines as a method argument for re.compile(). So, what I thought was r maybe stands for RegExp


regex = re.compile(



    r'[A-Z]$', re.IGNORECASE


But What does r means in this case?

1 Answer

0 votes
by (26.4k points)

It means, the respective string is considered to be a raw string. 

So, All the escape codes will be ignored.

How '\n' will be treated as newline character, same like r'\n' will be considered as characters \ followed by n.

Click on this link for more details about Python string literals

Want to know more about Python? Come and join: python certification course


Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories