Simple regex that has me banging my head against a wall
Timothy Grant
tjg at exceptionalminds.com
Wed Mar 21 18:02:05 EST 2001
On Wed, Mar 21, 2001 at 11:52:41PM +0100, Kalle Svensson wrote:
> 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 $.
>
I don't believe it is that simple.
>>> re.sub(r'\$', '\$', x)
'\\$1\\$asdfjke\\$lkjasdkjfsdasdfj'
That's why I'm a bit confused.
--
Stand Fast,
rhacer.
Timothy Grant, RHCE <>< MIG #1433
tjg at exceptionalminds.com '00 Marauder
www.exceptionalminds.com/rhacer Craigelachie
>>>>>>>>>>Linux, because rebooting is *NOT* normal.<<<<<<<<<<<
>>>>This machine was last rebooted: 64 days 3:17 hours ago<<
More information about the Python-list
mailing list