Raw string substitution problem

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Dec 19 04:29:32 CET 2009

On Sat, 19 Dec 2009 02:24:00 +0000, MRAB wrote:

> Gregory Ewing wrote:
>> MRAB wrote:
>>> In simple cases you might be replacing with the same string every
>>> time, but other cases you might want the replacement to contain
>>> substrings captured by the regex.
>> But you can give it a function that has access to the match object and
>> can produce whatever replacement string it wants.
>> You already have a complete programming language at your disposal.
>> There's no need to invent yet another mini-language for the replacement
>> string.
> There's no need for list comprehensions either, but they're much-used
> shorthand.

The same can't be said for regex replacement strings, which are far more 

And list comps don't make anything *harder*, they just make things 
easier. In contrast, the current behaviour of regex replacements makes it 
difficult to use special characters as part of the replacement string. 
That's not good.


More information about the Python-list mailing list