Simple regex that has me banging my head against a wall

Sean 'Shaleh' Perry shaleh at valinux.com
Wed Mar 21 18:33:19 EST 2001


> 
>>>> re.sub(r'\$', '\$', x)
> '\\$1\\$asdfjke\\$lkjasdkjfsdasdfj'
> 
> That's why I'm a bit confused.
> 

The double \ is printed by python.  If you do s = re.sub() and then print s, it
looks just fine.  I was confused by this when I tried it out myself.




More information about the Python-list mailing list