Re: [Pyparsing] C++ Comments and a Backslash at the End of the Line.
Brought to you by:
ptmcg
From: Paul M. <pa...@al...> - 2006-10-08 21:25:36
|
> -----Original Message----- > From: Ralph Corderoy [mailto:ra...@in...] > Sent: Sunday, October 08, 2006 8:19 AM > To: Paul McGuire > Cc: pyp...@li... > Subject: Re: C++ Comments and a Backslash at the End of the Line. > > > Hi Paul, > > > Care to try your hand at the re's for quoted strings? > > OK. > > _escapedChar = Regex(r"\\.") > > I don't think this is used anywhere? > > dblQuotedString = Regex(r'"([^"\n\r\\]|("")|(\\.))*"') > > There's not much you can do about this. Make it > non-capturing. Other than that, attempting to match many > [^"\n\r\\] at a time without going outside the group will > result in exponential behaviour on an unterminated string > because of backtracking. See > http://www.regular-expressions.info/atomic.html > > Unfortunately, Python's re module doesn't support Atomic > Grouping or Possessive Quantifiers, unlike, e.g. Perl. > That reminds me. Are these changes retro-compatible to Python 2.3? A while ago I added some features that made pyparsing no longer compatible with Python 2.2, and have kind of regretted it, so I'm really trying to stay compatible with at least Py2.3.2. Do you know off-hand if these features (such as non-capturing) work on Python 2.3.2? -- Paul |