[Python-Dev] Omission in re.sub?
Guido van Rossum
guido at python.org
Sun Dec 11 21:27:35 CET 2011
As long as there's a way to place a single backslash in the output
this seems fine to me, though I'm not sure it's important. Of course
it will likely break some test... the test will then have to be fixed.
I can't remember why we did this -- is there a full list of all the
escapes that re.sub() interprets somewhere? I thought it was pretty
limited. Maybe it's the related list of escapes that are supported in
On Sun, Dec 11, 2011 at 12:12 PM, MRAB <python at mrabarnett.plus.com> wrote:
> I've just come across an omission in re.sub which I hadn't noticed
> In re.sub the replacement string can contain escape sequences, for
>>>> repr(re.sub(r"x", r"\n", "axb"))
>>>> repr(re.sub(r"x", r"\x0A", "axb"))
> Yes, it doesn't recognise "\xNN".
> Is there a reason for this?
> The regex module does the same, but is there any objection to me fixing
> it in the regex module? (I'm thinking about compatibility with re here.)
> Python-Dev mailing list
> Python-Dev at python.org
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev