syntax incorrect with regex

Fredrik Lundh fredrik at pythonware.com
Fri Mar 18 17:23:59 CET 2005


"sam" wrote:

> What is the correct syntax of declaring a regex syntax in Python 2.3?
> I got the following error:
>
> # python2.3 test.py
>   File "test.py", line 10
>     macros_parser = re.compile (r""" (\s+)=\"(\s+)\"$ """,re.VERBOS)
>     ^
> SyntaxError: invalid syntax

compare and contrast:

>>> macros_parser = re.compile (r""" (\s+)=\"(\s+)\"$ """,re.VERBOSE)
(no error)

>>>     macros_parser = re.compile (r""" (\s+)=\"(\s+)\"$ """,re.VERBOSE)
  File "<stdin>", line 1
    macros_parser = re.compile (r""" (\s+)=\"(\s+)\"$ """,re.VERBOSE)
    ^
SyntaxError: invalid syntax

</F> 






More information about the Python-list mailing list