Raw string substitution problem
Lie Ryan
lie.1296 at gmail.com
Fri Dec 18 13:31:19 EST 2009
On 12/19/2009 4:59 AM, Alan G Isaac wrote:
> On 12/18/2009 12:17 PM, 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.
>
>
> Of course that "conversion" is needed in the replacement.
> But e.g. Vim substitutions handle this fine without the
> odd (to non perlers) handling of backslashes in replacement.
>
> Alan Isaac
Short answer: Python is not Perl, Python's re.sub is not Vim's :s.
Slightly longer answer: Different environments have different need;
vim-ers more often needs to escape with just a plain text. All in all,
the decision for default behaviors are often made so that less backslash
will be needed for the more common case in the particular environment.
More information about the Python-list
mailing list