[Pyparsing] Escaping quotes and such
Brought to you by:
ptmcg
From: Gre7g L. <haf...@ya...> - 2008-05-05 22:42:22
|
Hey guys! My parser has been working great, but I've run into a small snag in parsing C-style escapes. For example: >>> import pyparsing as PP >>> P = PP.QuotedString(quoteChar='"', escChar="\\") >>> P.parseString('"This is a quote: \\" This is a CR: \\n"') (['This is a quote: " This is a CR: n'], {}) As you can see, specifying escChar="\\" worked well at first, as the parser recognized that \" is a character in the string and not an end of quote. HOWEVER, when the \n didn't match the \" pattern it was looking for, instead of leaving it alone, it completely dropped the \. I need it to leave that \ intact so that I can find other string constants such as \n, \7, \xFF, etc. I do this by re-parsing the strings with my code. Perhaps that is not best? What should I do? TIA, Gre7g __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |