-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Regex for section_config() #60
Comments
Would supporting full line match suffice? There are implications and I would have to think them through for allowing just a regex. |
I was thinking in a more flexible way to get desired lines from the "config_parsed" object using the existing method We can force But it also works supporting full line match, wondering how we tell the method to do full match?
Thanks, |
Yes, I was thinking something like For |
I have another use-case for the regex feature: want to match: but not
This is currently only possible when using custom function. I think this would be a good improvement! |
Environment
When using section_config() function passing the sections is using "startswith" and will be convenient to use Regex.
Proposed Functionality
In file:
netutils/netutils/config/compliance.py
import re
line 421
if not match and line.config_line.startswith(line_start):
change to:
if not match and re.search(line_start, line.config_line):
Use Case
looking for specific access list names like:
ip access-list auto_golden_AB
having
we can extract the exact match defining the end of line ($):
section_config({'name':'ACL', 'ordered': True, "section":['ip access-list auto_golden_AB$']}, intended, 'cisco_nxos')
or the ones that have a number after (\d+):
section_config({'name':'ACL', 'ordered': True, "section":['ip access-list auto_golden_AB\d+']}, intended, 'cisco_nxos')
Thanks,
The text was updated successfully, but these errors were encountered: