[newbie] Strange behavior of the re module
Fred
fred at acme.com
Sat Aug 21 08:50:40 EDT 2004
On Sat, 21 Aug 2004 01:13:20 -0400, Tim Peters <tim.peters at gmail.com>
wrote:
>I can't figure out what you're trying to accomplish here, but the
>error msg makes sense.
I'm actually writing a script that extracts parts of HTML pages, but
some pages contain backslashes, which is why the script failed when
massaging those particular pages.
>>>> stuff=r"\colortbl\red0\gn0"
>>>> template = "BLA"
>>>> print re.sub('BLA', re.escape(stuff), template)
That did it :-) Thx a bunch.
Fred.
More information about the Python-list
mailing list