November 12th, 2013, 05:50 PM
Configuring Regex to find and exxlude words from router text configuration
I have been searching everywhere how to use a Regex in a Netwrok tool that I use from Cisco, the name is Network Compliance Manager.
I need that the Regex find me the interfaces that the status is down and the running port state is down. So I need to find the configuration text those 2 words, the problem that I have is that some interfaces are in state administratively down and when I use the Regex ^*down.*down.*$ it takes the administratively down interfaces too.
The config text look like this
Interface State RunningPortState
Gigaethernet0/4 down down
fastethernet1/2 administratively down down
fasethernet0/2 up up
So what I need is the regex to match the down down interfaces excluiding the ones that says administratively down, but It looks like imposible for me.
I hope you guys can help me, appreciatte your help a lot!!!!!!
November 12th, 2013, 08:00 PM
Number down down.
[a-z0-9]+/[0-9] down down
November 13th, 2013, 09:14 AM
Thanks you very much for your help! I really appreciatte it! Today I tried with this code you send me exactly as you wrote it, but it doesnt work, I dont know why, do you think that this can be a problem in the code? Its there some different way to look for the same with a bit different regex? number down down
Thank you really much
November 13th, 2013, 09:58 AM
Sorry for the bad information, but today I was checking what is the comand that the tool makes when searching for those regex and the output look like this exactly:
show ip interface brief
Interface IP-Address OK? Method Status Protocol
Vlan1 unassigned YES NVRAM administratively down down
Vlan30 10.136.1.4 YES NVRAM up up
FastEthernet1 unassigned YES NVRAM administratively down down
(I cant upload the image)
I still need to look for the down down interfaces!!
Thanks one more time
November 13th, 2013, 02:00 PM
might work, if the regex engine supports PCRE syntax.
(?<!administratively) down down
Otherwise try the same principle from before of matching what you want rather than not matching what you don't want.
Four words followed by "down down".
^[^ ]+ [^ ]+ [^ ]+ [^ ]+ down down$
November 13th, 2013, 04:24 PM
Thank you very much for your answer!! However didnt work for me, I tried both of them and the 2nd didnt worked at all when I put it tries to find the exact regular expresion so its looking in the configuration text for the pattern ^[^ ]+ [^ ]+ [^ ]+ [^ ]+ down down$ , the first one only searches for the word down that is under the protocol tab of the config text if I modify it like (?<!administratively) down , but when I write it exactly as you wrote it on the asnwer it just doesnt search for anything... I really just dont know what to do now. The only that worked a bit for me was ^*down.*down.*$ but it searches for the admin down interfaces too, do you think that the one that worked a bit can be modified in some way to make it work??
I know your regex are excellent I think it can be that the Cisco NCM doesnt support some simbols or some regex
Thanks again buddy
November 13th, 2013, 05:29 PM
Man Thanks alot for your help, I made some modifications in the REGEX you sent me and I write it like this ^*(?<!administratively) down.*down.*$ and worked perfectly, I think it was a shot of luck for me! Thanks, really thanks for all your help and time. Needed to do this for today at my job.
November 13th, 2013, 05:35 PM
Wondering if those spaces between the parts are actually tabs...
What little I can find about NCM suggests it supports the PCRE syntax I mentioned, so
If that works try the shorter and nicer
^[^ \t]+[ \t]+[^ \t]+[ \t]+[^ \t]+[ \t]+[^ \t]+[ \t]+down[ \t]+down$
November 13th, 2013, 06:16 PM
Yes I think those spaces are actually tabs, I really appreciatte your dedication and time one more time, that worked perfectly.