-
-
Notifications
You must be signed in to change notification settings - Fork 296
Closed
Description
Using pyparsing-2.4.7:
>>> from pyparsing import QuotedString
>>> quoted = QuotedString(quoteChar="\"", escChar=None, escQuote="\\\"")
>>> quoted.parseString('"abc"')
(['abc'], {})
>>> quoted.parseString('"abc \"def\""')
(['abc '], {})I am expecting the second example to return the entire string. A slightly easier case to read:
>>> quoted = QuotedString(quoteChar="y", escChar=None, escQuote="xy")
>>> quoted.parseString('yaaay')
(['aaa'], {})
quoted.parseString('yaaaxyaaay')
>>> quoted.parseString('yaaaxyaaay')
(['aaax'], {})
Compare both of the above with the use of a double:
>>> quoted = QuotedString(quoteChar="y", escChar=None, escQuote="yy")
>>> quoted.parseString('yaaay')
(['aaa'], {})
quoted.parseString('yaaayyaaay')
>>> quoted.parseString('yaaayyaaay')
(['aaayaaa'], {})
Looking at the code, the reason appears to be regex fun:
>>> quoted = QuotedString(quoteChar="y", escChar=None, escQuote="xy")
>>> quoted.pattern
'y(?:[^y\\n\\r]|(?:xy))*y'
This regex will not match yaaaxyaaay: https://regexr.com/5km7f
Metadata
Metadata
Assignees
Labels
No labels