Submit a ticketCall us

Announcing NCM 7.7
With NCM 7.7, you can examine the rules that make up an access control list for a Cisco ASA device. Then you can apply filters to display only rules that meet the specified criteria, order the rules by line number or by the hit count, and much more.
See new features and improvements.

Home > Success Center > Network Configuration Manager (NCM) > NCM use of Regular Expressions in Comparison Criteria

NCM use of Regular Expressions in Comparison Criteria

Table of contents
Created by Bill Corgey, last modified by MindTouch on Jun 23, 2016

Views: 347 Votes: 3 Revisions: 5


This article provides brief information on why .NET compliant Regular Expression may not be working if set up for use in the NCM Comparison Criteria.



All NCM versions


The following was taken from an Article written on Thwack by the NCM Product Manager.


Regular expressions are used in many places in the Network Configuration Manager (NCM). Because of technical and historical reasons, NCM uses a few different flavors of regular expressions for different functionality. In this post, I would like to explain the differences and provide references to more detailed documentation.



Informally, a regular expression is a search pattern (sequence of characters) used mainly for string pattern matching and string finding. The term originated in formal language theory where regular expressions are exactly defined and related to other concepts of the same power (regular languagesfinite automata, etc.). Although the current tools still use the term 'regular expression' (regex), it would be more precise to call them something like 'search patterns'; the expressive power of the search engine is, in fact, often much higher than that of the original regular expressions. (Many modern tools support patterns that are even more powerful than context-free languages.).



When you compare two config files for changes, you may want to ignore some of them. (Examples: certificates, last modification time.) Defining comparison criteria enables you to filter out of comparison results lines that you do not need NCM to evaluate; this saves both processing time and, more importantly, makes the review of compared files easier.


The regular expressions you create and enable in the settings (Settings -> NCM Settings -> Comparison Criteria) are used throughout NCM — for example, in performing scheduled jobs — wherever the software needs to compare config files as part of its work. A few criteria that are often used come with NCM out of the box; you can also define your own. The lines you typically want to ignore are often informational comments like when was the configuration changed last.


NCM uses the well-known diff tool (from the GNU Diffutils package - for config file comparisons. As you can find in Diffutils documentation - uses grep-style regular expressions; then it's not difficult to learn from GNU grep manual ( that the default regex flavour for grep are Basic Regular Expressions (BRE). Please note that the diff program works line by line -- you cannot define a regex that would match multiple lines.



·         Meta-characters ‘?’, ‘+’, ‘{’, ‘|’, ‘(’, and ‘)’ lose their special meaning; you must use the backslashed versions ‘\?’, ‘\+’, ‘\{’, ‘\|’, ‘\(’, and ‘\)’. In other words, you will use backslashes to give certain characters special meaning, while many other regex implementations use backslashes to take the special meaning away.

·         You have to use '%%' in the pattern when you want to match '%'.


More details on BRE syntax can be found




Last modified
21:27, 22 Jun 2016