regex ?

Greg Krohn infinitystwin.SPAM at IS.BAD.yahoo.com
Thu Jan 3 15:23:52 EST 2002


"David A McInnis" <david at dataovation.com> wrote in message
news:mailman.1010083385.12710.python-list at python.org...
> When title has an ' or " this appears to crash.
>
> re.compile(r"<title>(.*)</title>", re.I)
>
> Any ideas?
>
> David

Works for me:

import re
sampleData = "Spam, spam, <GREEN>ham</GREEN>. " \
                + "<TITLE>Here's lookin' at you, kid.</TITLE> " \
                + "Say no more."

pat = re.compile(r"<title>(.*)</title>", re.I)

match = pat.search(sampleData)

if match:
    print match.groups()
else:
    print "No matches"

>>> ("Here's lookin' at you, kid.",)





More information about the Python-list mailing list