[Tutor] backreferences - \0

Payal payal-tutor at scriptkitchen.com
Sun Jun 6 15:44:06 CEST 2010


On Sun, Jun 06, 2010 at 07:52:43PM +1000, Lie Ryan wrote:
> >>> re.sub('(one) (two)', r'\g<0> - \1 \2',s)
> 
> the \g<number> is equivalent to \number but is intended to ambiguate
> cases like "\g<2>0" vs. "\20". It happens that \g<0> refers to the
> entire group.

Thanks a lot. It works as you say.

With warm regards,
-Payal
-- 



More information about the Tutor mailing list