using re.finditer()

Peter Otten __peter__ at web.de
Wed Oct 27 17:43:54 EDT 2004


Erik Johnson wrote:

> I am still left puzzled though, why this won't work:
> 
> pat = r'<td.*?>([\n.]*?)</td>'
> for match in re.finditer(pat, html):
> print match.group(1)

>>> re.findall(r"[.\n]", "\nx\n")
['\n', '\n']
>>> re.findall(r"[.\n]", "\n.\n")
['\n', '.', '\n']

It seems a dot inside [] means a dot rather than "any character".

Peter



More information about the Python-list mailing list