[Tutor] backreferences - \0

Payal payal-python at scriptkitchen.com
Sun Jun 6 09:32:26 CEST 2010


Hi,
A newbie re query.

>>> import re
>>> s='one'
>>> re.sub('(one)','only \\0',s)
'only \x00'
>>> re.sub('(one)','only \0',s)
'only \x00'

I expected the output to be 'only one' with \0 behaving like "&" in sed.
What is wrong with my syntax?

With warm regards,
-Payal
-- 


More information about the Tutor mailing list