Submit a ticketCall us

Welcome to the NEW Success Center. Search all resources (documentation, videos, training, knowledge base articles) or browse resources by product. If you are unable to find what you are looking for, please contact us at customersuccess@solarwinds.com

 

 

 

 

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: 1,425 Votes: 2 Revisions: 5

Overview

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.

 

Environment

All NCM versions

Detail

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.

 

WHAT ARE REGULAR EXPRESSIONS

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.).

 

REGULAR EXPRESSIONS FOR COMPARISON CRITERIA

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 - http://www.gnu.org/software/diffutils/) for config file comparisons. As you can find in Diffutils documentation - http://www.gnu.org/software/diffutil...pecified-Linesdiff uses grep-style regular expressions; then it's not difficult to learn from GNU grep manual (https://www.gnu.org/software/grep/ma...ar-Expressions) 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 http://www.regular-expressions.info/gnu.html.

 

 

 

Last modified
21:27, 22 Jun 2016

Tags

Classifications

Public