Problem with RE matching backslash

Ladvánszky Károly aa at bb.cc
Tue Jan 27 16:11:19 CET 2004


What is the correct way to match/search a backslash with regular
expressions?

print re.match('\\m', '\\m').group(0)  raises an error while
print re.search('\\m', '\\m').group(0) yields 'm'

print re.search('\\m', '\m').group(0) yields 'm'
print re.search('\\m', 'm').group(0) yields  'm'

Any helpful comment on this would be appreciated,

Károly





More information about the Python-list mailing list