Menu

#96 Strange StringStart().scanString behaviour

v1.0 (example)
open
nobody
None
5
2016-07-29
2016-07-29
No

Here is a log from an interactive session of mine (pyparsing 2.1.5):

>>> from pyparsing import StringStart
>>> StringStart().parseString("")
([], {})
>>> StringStart().parseString(" ")
([], {})
>>> StringStart().parseString("text")
([], {})
>>> StringStart().parseString(" text")
([], {})
>>> list(StringStart().scanString(""))
[]
>>> list(StringStart().scanString(" "))
[(([], {}), 1, 1)]
>>> list(StringStart().scanString("text"))
[]
>>> list(StringStart().scanString(" text"))
[(([], {}), 1, 1)]

It seems that something very strange is going on in the interaction with StringStart and scanString. For some reason, StringStart only finds a match when the string starts with whitespace, but only when using scanString, not parseString.

Is this intended behaviour? It causes StringStart to be basically useless when used with scanString, since it does not actually always match the start of the string.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.