Regular Expressions

Ron ronpro at cox.net
Wed Mar 23 02:23:13 CET 2005


This is probably a repeated question, but try as I might I was unable
to find something similar in the archives.

I'm trying to develop a regular expression for recognizing a simplified
C-Style string syntax.  I need it to be able to handle escape sequences
of the form \x where x is any character including ".

Here's what I'm trying:

  \"([^"\\]|(\\.))*\"

When I try to get it to recognize something like:

   "I said, \"Hello!\""

It stops at the first quote after the \.

I've used this very same regular expression in a parser generator I
have for C++ and it works just fine.

Any thoughts on what I'm doing wrong in the Python Reg Ex world?

Thanks for the comments & help.

Ron




More information about the Python-list mailing list