Q: re

Kalle Svensson kalle at gnupung.net
Tue Oct 24 16:19:10 EDT 2000


On Tue, 24 Oct 2000, Hwanjo Yu wrote:

> Hi,

Hi!

[snip]
> >>> matchstr = re.compile(r".*homepage | .*~.*", re.IGNORECASE)
> >>> re.match(matchstr, "http://www.my.com/me/homepage")
> 
> In this case, this should return matchobject since it matches the
> "homepage", but it doesn't.
> What is wrong here ?

The regexp should be:
>>> matchstr = re.compile(r".*homepage|.*~.*", re.IGNORECASE)
>>> # No whitespace -----------------^^^
...
>>> matchstr.match("http://www.my.com/me/homepage")
<re.MatchObject instance at 8086328>

Your regexp tried to match ".*homepage " or " .*~.*", with the spaces.

HTH,
  Kalle
-- 
Email: kalle at gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
Not signed due to logistical difficulties (I'm not at home).
If you doubt the authenticity of this message, please tell me.




More information about the Python-list mailing list