regex ?

Alex Martelli aleax at aleax.it
Fri Jan 11 09:47:30 EST 2002


"Chris Dutton" <cmbchris at mac.com> wrote in message
news:B8635129.1A6C%cmbchris at mac.com...
> in article 3c34bcc9$0$79560$6e49188b at news.goldengate.net, Greg Krohn at
> infinitystwin.SPAM at IS.BAD.yahoo.com wrote on 1/3/02 3:23 PM:
>
> > pat = re.compile(r"<title>(.*)</title>", re.I)
>
> Or just in case somebody puts two set of titles in one document, for
> whatever reason...
>
> pat = re.compile(r"<title>([^</title>]+)</title>", re.I)

No!!!  The part [^</title>] excludes any of the CHARACTERS lessthan,
slash, t, i, l, e, and greaterthan, from being accepted as part of
a title.  This is VERY unlikely indeed to be what one would want.


Alex






More information about the Python-list mailing list