Simple regex that has me banging my head against a wall
Emile van Sebille
emile at fenx.com
Wed Mar 21 18:17:02 EST 2001
In 2.0,
'$1$asdfjke$lkjasdkjfsdasdfj'.replace('$',r'\$')
but then I don't tend to use re's for this kind of thing. Is there some
advantage I'm not seeing?
Emile van Sebille
emile at fenx.com
"Timothy Grant" <tjg at exceptionalminds.com> wrote in message
news:mailman.985213768.20178.python-list at python.org...
> 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)
> '\\\\$1\\\\$asdfjke\\\\$lkjasdkjfsdasdfj'
>
> All I want to do is substitute \$ for $.
>
> Thanks.
>
> --
> Stand Fast,
> tjg.
>
> Timothy Grant tjg at exceptionalminds.com
> Red Hat Certified Engineer www.exceptionalminds.com
> Avalon Technology Group, Inc. <>< (503) 246-3630
> >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<
> >>>>This machine was last rebooted: 64 days 2:43 hours ago<<
>
More information about the Python-list
mailing list