Problem with RE matching backslash

Ladvánszky Károly aa at bb.cc
Tue Jan 27 10:11:19 EST 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