Simple regex that has me banging my head against a wall
kalle at gnupung.net
Wed Mar 21 23:52:41 CET 2001
Sez Timothy Grant:
> Hi again.
> I actually thought I had this regex thing down pretty well, but
> I'm getting beat up by what I thought should be a simple one.
> >>> x = '$1$asdfjke$lkjasdkjfsdasdfj'
> >>> re.sub(r'\$', r'\\\$', x)
One \ too many, it seems. The second argument to re.sub is not a regex, so
you don't have to escape the $.
> All I want to do is substitute \$ for $.
Email: kalle at gnupung.net | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
[ Not signed due to lossage. Blame Microsoft Outlook Express. ]
More information about the Python-list