05-25-2011 02:59 PM
I'm
having problems with a regexp, I'm trying to search for multiple patterns in the loopback description field:
Example:
Rtr1:
interface loopback0
description rndm:text:cursor:1536:blah:blah1
Rtr2:
interface loopback0
description rndm:text:cursor:3072:blah:blah1
The regular expression that works is:
+interface Loopback0
+ [#description .*:.*:.*:1536:.*#]
But that only searches for one instance, what I cannot get to work is the following:
+interface Loopback0
+ [#description .*:.*:.*:1536|3072:.*#]
I have tried many variants, but I cannot get the (pipe) to work properly.
Thanks in advance for any help,
Craig
05-27-2011 12:59 AM
Try:
+ [#description .*:.*:.*:(1536|3072):.*#]
05-27-2011 09:28 AM
Nope, still no luck, I did have to add \ in front of the
colons to get the specific location, the asteriks wwould allow it to search for that sting any
where in the description, but I couldn't get the pipe to work properly still, I've trie
d moving the hard brackets, paranthesis etc.
I ended up working around the problem, by creating individual lines:
+[#description .*\:.*\:.*\:1536\:.*\:.*\:.*#]
+[#description .*\:.*\:.*\:3072\:.*\:.*\:.*#]
+[#description .*\:.*\:.*\:2048\:.*\:.*\:.*#]
Then running the report, the report gave the output of which commands needed to be "added", so I used a seperate program to determine which devices were non-compliant, IE.
If router one needed all 3 of those commands, then I knew it did not match any of them, and was non-compliant, if router two only needed 2 of those commands, I knew that it was compliant.
Kind of a backwards approach, and I would still like to see the search work.
Thanks for the help,
Craig
05-27-2011 04:41 PM
The \ is not required as ':' is not a regular expression meta-character. I tested with the parentheses and it's working for me. What you want is certainly doable with one expression. It seems like perhaps you didn't share the actual descriptions. It may be helpful to see the actual config snippets to test more completely.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide