Simple regex that has me banging my head against a wall

Sean 'Shaleh' Perry shaleh at
Thu Mar 22 00:33:19 CET 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