\l operation in regular expressions

Kalle Anka skromta at gmail.com
Tue May 24 09:23:53 EDT 2005


I've started to play around with regexps in Python and I tried
something like this

print re.sub( r'(\bw\w+\b)', r'\u\1', 'will it work')

and get

\uwill it \uwork

when I had expected

Will it Work

I tried to find some documentation about this but I can't find anything
that says if operations like \l \L \u \U etc are supported or not. It
doesn't look like it supported? What is the "Python way" of doing this,
writing a function and use that as the replacement?





More information about the Python-list mailing list