Document toolboxDocument toolbox

Regular Expressions Usage

NetMRI uses regular expressions similar to those supported by Cisco, JavaScript and Unix programming languages. Regular expressions supported for table filtering consist of a sequence of special symbols, modifiers and normal characters. NetMRI interprets the following single characters and expressions as follows:

^ Matches the beginning of the string

$ Matches the end of the string

. Matches any single character

[...] A set of matching characters such as [aeiouA-Z]

[^...] A set of non-matching characters

(...) A sub-pattern to be modified or remembered

(...|...) A set of alternate sub-patterns

\w Matches any word character; same as [a-zA-Z0-9]

\W Matches any non-word character; same as [^a-zA-Z0-9_]

\s Matches any whitespace character; same as [ \t\n\r\f\v]

\S Matches any non-whitespace character; same as [^ \t\n\r\f\v]

\d Matches any digit; same as [0-9]

\D Matches any non-digit; same as [^0-9]

To match any of the special characters above, enter the backslash (\) escape character immediately before them. Avoid spurious or excessive matches. To match all IP addresses starting with an initial octet of 10, use /10\./ as the pattern, not /10./ which matches 10., 100, 101, 102, etc. (remember, dot is a special symbol).

Examples:

$Vendor like /Cis.*/

$Type like /.*Switch.*/

$IPAddress like /10\.*[/]16/

Note

A common mistake occurs by using the Unix wildcard syntax (*) instead of the regular expression syntax (.*) to match any sequence of characters.