RE Module How to escape $
wurmy at earthlink.net
Sat Jun 8 17:35:32 CEST 2002
> 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
>>> import re
>>> s = "I have $amount dollars"
>>> re.sub("\$\S+", "foo", s)
'I have foo dollars'
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/
More information about the Python-list