This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Comparison Criteria - RegEx questions

When comparing running to either startup I always run across  a self-signed certificate in the running config that is loaded from NVRAM.  I have tried modifying some of the examples from the manual, but it doesn't ever seem to do the trick.

For example:

I have a line that begins with

crypto pki trustpoint

and I want to ignore from that line through any number of lines until it sees

quit

and I have tried using this expression ^crypto pki trustpoint.*.*\n(.*\n)*.*^quit

 

So far I have had little to know success.

  • Thanks for your post.  What version of NCM are you currently running?

    You may want to try the following regex for the first line

    ^[ \t\r\n\v\f]*crypto[ \t\r\n\v\f]*pki

    Can you please post the content from "crypto pki" to "quit"?

    The thing to keep in mind is that the regex is matched on a per line basis.  When multiple lines are different from one compare to another at least one regular expression match must exist in the list regex for each line.

    The diff utility finds a group of changes and puts them into a change blob.  A change blob can comprised of one or more different lines. 

    Here is an example of change blob.  You'll notice that there are five lines, that could be matched with three unique regex.

    crypto pki

    3001ABF1 2345ABCD FEDC0001

    3241ABF1 29876AFCD FEDC0002

    9876ABF2 48576AFCD FFFF0003

    quit

    So you will need the following regexs to be entered in NCM. Notice how they only match the start of the line and don't need to match the entire line.

    ^[ \t\r\n\v\f]*crypto[ \t\r\n\v\f]*pki

    ^[ \t\r\n\v\f]*[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]

    ^[ \t\r\n\v\f]*quit[ \t\r\n\v\f]*

    For each line in the change blob, the system looks in our list of defined regular expression to find a match. If no match is found, for even a single line, then entire blob is listed as a change.  If there is a regex match for each line changed line in the blob, the blob is ignored.

    So if you only had the first and last regex listed then the whole change blob is displayed.  It's an all or nothing system.

    I hope this helps.

  • We are currently running 5.1, but once we get our NPM upgrade to 9.5 completed we are wanting to bring it up to the latest and greatest.

     

    The example you gave is pretty much what we are looking at here, just more of it.  I will definitely give this a go.

    Thanks for the assistance!