You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support for matching a pattern repeatedly on the same line #69
If breaking out, it would be great to get your interpretation of the potential solution. Hard for an outside reader to decompose based on title and reference alone.
support for capture of multiple matches per field per line.
example text to match: key1:val1, key2:val2, key3:val3 ...
where the number of times this is repeated is arbitrary.
You would think to go about a match as so:
Value keys (\S+)
Value vals (\S+)
Start
^({keys}:{vals},\s?)+
but python re does not support this and would only give you key3 and val3.
Pull request adds a dependency to a different regex parsing module which has this functionality and is backwards compatible with re. Other solutions would include post processing (some functionality could be lost), or making repeated matches very general then going through the general match recursively as you strip layers of parenthesis, which would be ugly to implement.
There are examples and test cases in #38 if you want to see the functionality of some edge cases.
It's been a while but IIRC the blocker for this is template compatibility. As alternate implementations, such as golang (#64) uses a different regexp engine (or at least they did).
So if the python instance supports regexp functionality that is not a common denominator across implementations then the template libraries would need to be split, as different templates would be required depending on the textfsm instance.
Adding this would preclude using a common template library across implementations, not just the golang implementation above but any implementation (now or in future) that uses this different regexp implementation.
If there's a way to meet this feature request within this POSIX standard then we should definitely do it! Otherwise probably not unless popular alternate languages, like golang, rust etc converge on supporting the same (extended)ERE behaviour similar to the library suggested for Python.
The final call on this would probably be up to @itdependsnetworks as he maintains the template libraries, and would be most impacted by this change?
If there's a way to meet this feature request within this POSIX standard then we should definitely do it! Otherwise probably not unless popular alternate languages, like golang, rust etc converge on supporting the same (extended)ERE behaviour similar to the library suggested for Python.
I don't think there is a need for a new library. Not sure why this can't be done in the existing RE engine (haven't looked at the PR that much TBH however). You would have to use python's finditer instead of match but I think it is doable. Might not be quite that simple but should be pretty close. I don't think Repeatable needs to do anything on the line itself (like actually do the repeating, just that the keyword should enable repeating) because there may be additional things people want to do, ex:
Value Key VID (\d+)
Value Key Name (\S+)
Value Repeatable,List INTERFACES (Gi\d/\d/\d+)
Start
^\d+ -> Continue.Record
^${VID}\s+${Name}\s+active\s+(${INTERFACES}+,?)
^\s+(${INTERFACES}+,?)
Something like that, which lets you repeat would be gravy
Reacted by Josh VanDeraa, giovanni-bellini-argo, James F and JKLs12
Activity
itdependsnetworks commentedon Nov 16, 2019
If breaking out, it would be great to get your interpretation of the potential solution. Hard for an outside reader to decompose based on title and reference alone.
gachteme commentedon Nov 18, 2019
support for capture of multiple matches per field per line.
example text to match:
key1:val1, key2:val2, key3:val3 ...where the number of times this is repeated is arbitrary.
You would think to go about a match as so:
but python re does not support this and would only give you key3 and val3.
Pull request adds a dependency to a different regex parsing module which has this functionality and is backwards compatible with re. Other solutions would include post processing (some functionality could be lost), or making repeated matches very general then going through the general match recursively as you strip layers of parenthesis, which would be ugly to implement.
There are examples and test cases in #38 if you want to see the functionality of some edge cases.
[-]Repeat option support[/-][+]Support for matching a pattern repeatedly on the same line[/+]boniek83 commentedon Mar 9, 2020
This is useful. Are you guys planning on merging this anytime soon?
DanSheps commentedon Sep 29, 2021
Has there been any movement on this at all?
giovanni-bellini-argo commentedon Jun 21, 2024
👀 still in future plans?
harro commentedon Oct 4, 2024
It's been a while but IIRC the blocker for this is template compatibility. As alternate implementations, such as golang (#64) uses a different regexp engine (or at least they did).
So if the python instance supports regexp functionality that is not a common denominator across implementations then the template libraries would need to be split, as different templates would be required depending on the textfsm instance.
giovanni-bellini-argo commentedon Oct 4, 2024
As far as i can see the go implementation linked in the discussion isn't maintained, wouldn't there be more gains in mergin this?
harro commentedon Nov 28, 2024
Adding this would preclude using a common template library across implementations, not just the golang implementation above but any implementation (now or in future) that uses this different regexp implementation.
harro commentedon Jan 8, 2025
My inclination is to close this as 'working as intended', as in, we implement a widely supported set of regexp behaviours per the POSIX extended regular expressions standard: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html
If there's a way to meet this feature request within this POSIX standard then we should definitely do it! Otherwise probably not unless popular alternate languages, like golang, rust etc converge on supporting the same (extended)ERE behaviour similar to the library suggested for Python.
The final call on this would probably be up to @itdependsnetworks as he maintains the template libraries, and would be most impacted by this change?
itdependsnetworks commentedon Jan 8, 2025
@jmcgill298 @mjbear @jvanderaa any thoughts?
DanSheps commentedon Jan 9, 2025
I don't think there is a need for a new library. Not sure why this can't be done in the existing RE engine (haven't looked at the PR that much TBH however). You would have to use python's finditer instead of match but I think it is doable. Might not be quite that simple but should be pretty close. I don't think Repeatable needs to do anything on the line itself (like actually do the repeating, just that the keyword should enable repeating) because there may be additional things people want to do, ex:
Something like that, which lets you repeat would be gravy