RE Module How to escape $

Prema prema at prema.co.nz
Sat Jun 8 21:31:59 EDT 2002


Hi Hans!
Thanks so much for your post -- it works perfectly.
I had been head bashing for a while on that one for some reason.
Thanks for getting back so quickly
Best regards 
Mike

Hans Nowak <wurmy at earthlink.net> wrote in message news:<3D0223D5.4050900 at earthlink.net>...
> Prema wrote:
> > Hi People !
> > I'm trying to use the re.sub function to replace several instances of a
> > PHP Variable eg "$Amount". Could someone please help with an example
> > Thanks very much
> > Mike
> 
> Sure...
> 
>  >>> import re
>  >>> s = "I have $amount dollars"
>  >>> re.sub("\$\S+", "foo", s)
>  'I have foo dollars'
>  >>>
> 
> HTH,



More information about the Python-list mailing list