regex question

Paul McGuire ptmcg at
Mon Jan 8 09:44:20 CET 2007

"proctor" <12cc104 at> wrote in message 
news:1168243020.304940.212700 at
> it does work now...however, one more question:  when i type:
> rx_a = re.compile(r'a|b|c')
> it works correctly!

Do you see the difference between:

rx_a = re.compile(r'a|b|c')


rx_a = re.compile("r'a|b|c'")

There is no difference in the variable datatype between "string" and "raw 
string".  Raw strings are just a notational helper when creating string 
literals that have lots of backslashes in them (as happens a lot with 

r'a|b|c'  is the same as 'a|b|c'
r'\d' is the same as '\\d'

There is no reason to "add raw strings" to your makeRE method, since you 
don't have a single backslash anywhere.  And even if there were a backslash 
in the 'w' argument, it is just a string - no need to treat it differently.

-- Paul 

More information about the Python-list mailing list