Regular Expressions to Replace Strings
Alex Martelli
aleaxit at yahoo.com
Fri May 18 08:53:07 EDT 2001
More information about the Python-list mailing list
Fri May 18 08:53:07 EDT 2001
- Previous message (by thread): Regular Expressions to Replace Strings
- Next message (by thread): Python prints the wrong international letters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
<piet at cs.uu.nl> wrote in message news:uitiygb6y.fsf at cs.uu.nl... > >>>>> Andrew Kuchling <akuchlin at mems-exchange.org> (AK) writes: > > AK> Group 0 corresponds to the match as a whole, so you could use \0 in > AK> your replacement pattern. > > In my python 2.0 \0 doesn't work. It just inserts a \0 character. True (in both 2.0 and 2.1, it seems) -- you appear to need the alternative \g<0> syntax, for some reason... this works: import re base = 'tanto va la gatta al lardo' vow = re.compile('a|o') resu = vow.sub(r'"\g<0>"', base) print resu Alex
- Previous message (by thread): Regular Expressions to Replace Strings
- Next message (by thread): Python prints the wrong international letters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list