I am changing a few pyparsing patterns from pyparsing version 2 to pyparsing version 3.
The contents of the sample file I use for parsing
this is a sample page to test parsing
line 0001 line 1
line 0002 line 2
the pattern used to create parser
p.Literal('line ') + p.Regex(r'(?P<abc>\d+)') + p.SkipTo(p.LineEnd().suppress())
When I using the locatedExpr from version2 I get the following output
{'locn_start': 55, 'abc': '0002', 'value': ['line ', '0002', ' line 2'], 'locn_end': 71}
when I use Located from version 3 I get the following output for the same pattern
{'locn_start': 55, 'value': {'abc': '0002'}, 'locn_end': 71}
However if I remove the named capturing group from the pattern like below example
[p.Literal('line ') + p.Regex(r'\d+')] + p.SkipTo(p.LineEnd().suppress())
I get the same output as locatedExpr
{'locn_start': 55, 'value': ['line ', '0002', ' line 2'], 'locn_end': 71}
However I like to group the information in my parsing and I was wondering if anybody know the difference between Located and locatedExpr
In all the above cases I am using parse_with_tabs
[p.Literal('line ') + p.Regex(r'\d+')] + p.SkipTo(p.LineEnd().suppress())?locatedExpris deprecated in favor ofLocated, introduced in 3.0.0.