Regex doesn't support MULTILINE?

Tony Meyer tony.meyer at gmail.com
Sat Jul 21 22:55:53 EDT 2007


> I'm trying to extract information from a web page using the Re module,
> but it doesn't seem to support MULTILINE:
[...]
> Do I need to add something else to have Re work as intended?

I believe you are looking for DOTALL, not MULTILINE.  From the
documentation:

"""
M
MULTILINE
When specified, the pattern character "^" matches at the beginning of
the string and at the beginning of each line (immediately following
each newline); and the pattern character "$" matches at the end of the
string and at the end of each line (immediately preceding each
newline). By default, "^" matches only at the beginning of the string,
and "$" only at the end of the string and immediately before the
newline (if any) at the end of the string.

S
DOTALL
Make the "." special character match any character at all, including a
newline; without this flag, "." will match anything except a newline.
"""

If you do a lot of working with regular expressions, then I highly
recommend Kodos (http://kodos.sourceforge.net) as a tool for
interactively figuring out issues.

Cheers,
Tony Meyer




More information about the Python-list mailing list