[issue2636] Regexp 2.7 (modifications to current re 2.2.2)
Matthew Barnett
report at bugs.python.org
Mon Mar 23 00:33:31 CET 2009
Matthew Barnett <python at mrabarnett.plus.com> added the comment:
An additional feature that could be borrowed, though in slightly
modified form, from Perl is case-changing controls in replacement
strings. Roughly the idea is to add these forms to the replacement string:
\g<1> provides capture group 1
\u\g<1> provides capture group 1 with the first character in uppercase
\U\g<1> provides capture group 1 with all the characters in uppercase
\l\g<1> provides capture group 1 with the first character in lowercase
\L\g<1> provides capture group 1 with all the characters in lowercase
In Perl titlecase is achieved by using both \u and \L, and the same
could be done in Python:
\u\L\g<1> provides capture group 1 with the first character in
uppercase after putting all the characters in all lowercase
although internally it would do proper titlecase.
I'm suggesting restricting the action to only the following group. Note
that this is actually syntactically unambiguous.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2636>
_______________________________________
More information about the Python-bugs-list
mailing list