google / textfsm

Python module for parsing semi-structured text into python tables.
Apache License 2.0
1.09k stars 168 forks source link

Add Repeated option and port re to regex module. #38

Open gachteme opened 5 years ago

gachteme commented 5 years ago

Fixes #18

Instances of re were changed to regex. This allows for increased matching power. Repeated data parsing as asked for in issue #18 was added using the new regex module functionality. Test cases were updated to reflect the increased functionality and new option.

buxtronix commented 5 years ago

I'm a little hesitant to use a non-standard regex parser here, as it constrains textfsm too much. In particular, we are planning to port to other languages which are compatible with the same templates. Use of a regexp engine that is not RE2 compliant (and only RE2 compliant) will jeopardise those plans.

gachteme commented 5 years ago

The regex module is (and plans to be) fully backwards compatible with re. It does allow for some extra functionality, and doesn't python's re already support lookaheads/lookbehinds (?=re) which are not supported by RE2? I can see a reason to be hesitant with using any third-party packages though. If absolute consistency (IE: throwing errors when something is supported in the language used but not all supported languages) between languages is desired a check could be added for regex RE2 compliance.

gachteme commented 5 years ago

My bad, you meant it to apply to the multiple captures portion that was being leveraged. I'll do some checking to see if this is doable with pyre2.

harro commented 5 years ago

According to https://github.com/google/re2/wiki/Syntax re2 would not be an option

gachteme commented 4 years ago

~~I'm seeing the merge from #55 causes errors in python 2.7, is that no longer supported? If this is the case then~~ this should be ready for review. The only caveat is that I don't have an automated way of running the test suite with an environment containing the re module versus the regex module. I have manually run the tests in both environments.