What does r mean before a Regex pattern

0 votes
I found the following regex substitution example from the manual for Regex. I'm a little bit unclear as to what the prefix r does before the string?

re.sub(r'def\s+

([a-zA-Z ][a-zA-Z 0-9]*)\s*\(\s*\):',

... r'static PyObject*\npy_\1(void)\n{',

... 'def myfunc():')
Jun 22 in Data Analytics by avinash
• 860 points
6 views

1 answer to this question.

0 votes
Since the string is to be treated as a raw string (r), any escape codes will be disregarded.

The Python documentation specifically states:

It is optional to precede string literals with the letter "r" or "R"; these strings are known as raw strings and employ alternative methods for interpreting backslash escape sequences.
answered 6 days ago by Sohail
• 2,960 points

Related Questions In Data Analytics

+1 vote
1 answer

R has something called lazy evaluation, what does that mean?

Let me explain this with an example. ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 52,350 points
629 views
0 votes
1 answer

What does the inf special character mean in R?

inf stands for infinity and only applies ...READ MORE

answered Nov 14, 2018 in Data Analytics by Maverick
• 10,840 points
734 views
0 votes
1 answer
0 votes
1 answer

What is a Random Walk model and how can you simulate it using R?

A random walk is a simple example ...READ MORE

answered Jul 3, 2018 in Data Analytics by DataKing99
• 8,240 points
2,518 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
422 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
467 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
4,287 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
492 views
0 votes
1 answer

What does the double percentage sign (%%) mean?

According to the "Arithmetic operators" help page ...READ MORE

answered Jun 14 in Data Analytics by Sohail
• 2,960 points
12 views
0 votes
1 answer

What does "pch" stand for?

Plot character or pch is the standard ...READ MORE

answered Jun 23 in Data Analytics by Sohail
• 2,960 points
27 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP