Refer to this HOWTO regex for python3
https://docs.python.org/3/howto/regex.html#performing-matches
>>> p = re.compile('\d+') >>> p.findall('12 drummers drumming, 11 pipers piping, 10 lords a-leaping') ['12', '11', '10']
I read that for a regular expression containing '\' , raw strings should be used as r'\d+' , but in this code fragment re.compile('\d+') used without using the r specifier. And it works great. Why does this work in the first place? Why doesn't this regular expression need the “r” preceding it?
source share