Error in re-module?

Fredrik Lundh effbot at telia.com
Wed May 10 15:39:33 EDT 2000


ee <webers at bigfoot.de> wrote:
> I have some trouble with the re-module. I tried the follwing Perl-style
> regular expression with Python 1.6 (cvs-checkout 20000510):
> 
> [PYTHON (1.6/cvs-version 20000510)]
> > line = '"(" XYZ ")"'
> > match = re.match('^(?P<token>"((\\")|[^"])*")(?P<data>.*)$', line)
> [/PYTHON]

\\" doesn't mean what you think it does.  to get the quoting right,
use a raw string instead:

    match = re.match(r'^(?P<token>"((\\")|[^"])*")(?P<data>.*)$', line)

</F>




More information about the Python-list mailing list