Simple regex that has me banging my head against a wall
drew.csillag at starmedia.net
Thu Mar 22 00:27:16 CET 2001
On Wed, Mar 21, 2001 at 02:31:44PM -0800, Timothy Grant wrote:
> 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)
> All I want to do is substitute \$ for $.
Python 2.1b1 (#1, Mar 4 2001, 11:31:25)
[GCC 2.95.2 19991024 (release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> x = '$1$asdfjke$lkjasdkjfsdasdfj'
>>> import string
>>> print string.replace(x, '$', r'\$')
Acting Manager of Platform Engineering
drew.csillag at starmedia.net Cell: (917)-679-8827
StarMedia Network, Inc. Land: (212)-905-8332
More information about the Python-list