Pyparsing: the differences between MatchFirst, Or, and oneOf -
in pyparsing, differences between matchfirst, or, , oneof
when there shared characters in strings like
word, wording, words
or(['word', 'wording', 'words'])
matchfirst(['word', 'wording', 'words'])
oneof(['word', 'wording', 'words'])
from online docs (https://pythonhosted.org/pyparsing/)
matchfirst - if 2 expressions match, first 1 listed 1 match.
or - if 2 expressions match, look matches longest string used.
oneof - helper define set of alternative literals, , makes sure longest-first testing when there conflict, regardless of input order, returns matchfirst best performance.
matchfirst tests current parse location each string in constructor, stopping @ first 1 match.
or tests current parse location against of strings given in constructor, , homecoming longest match.
oneof generates regex or matchfirst match longest match, reordering input list when there alternatives mutual start strings test longer string first.
pyparsing
No comments:
Post a Comment