word wrap in regex

John Machin sjmachin at lexicon.net
Tue Jun 4 00:23:13 CEST 2002


Sabine Richter <sabine at textraeume.de> wrote in message news:<mailman.1023127745.29025.python-list at python.org>...
> Hello,
> 
> I have a regex which is a bit long (200 characters) and I want to add
> word wraps and comments to make it more clear. I'm sure I read about
> that in the references before but I don't find the passage with the word
> wrap no more. May anybody give me a hint?
> 
> Sabine

It is in the "module contents" section. You need to specify a flag as
an optional argument. You can have not only "word wraps" and comments
but also whitespace between conceptual "words".

"""
X

VERBOSE
This flag allows you to write regular expressions that look nicer.
Whitespace within the pattern is ignored, except when in a character
class or preceded by an unescaped backslash, and, when a line contains
a "#" neither in a character class or preceded by an unescaped
backslash, all characters from the leftmost such "#" through the end
of the line are ignored.
"""

If you are having trouble parsing the second sentence, try
substituting "nor" instead of the second "or".



More information about the Python-list mailing list