Top
Systemwalker Operation Manager V17.0.1 Reference Guide

15.2.16 regexp (Perform Regular Expression Matching and Extract the Matched Part)

Description

Matches a regular expression against a string and extracts matched parts.

Synopsis

regexp exp string[matchvar] [submatchvar1 submatchvar2 ... ]

Options

exp

Specify a regular expression.

string

Specify the string to check.

matchvar

Specify the name of the variable in which parts of string that matched the regular expression are extracted and stored. If omitted, the matching parts will not be stored.

submatchvar

Specify the name of the variable in which parts of string that matched the parenthesized substrings are extracted and stored. If omitted, the matching parts will not be stored.

Point

A regular expression is a shorthand for describing the structure of a string using symbols. This command checks whether the string specified in the string option has a part that matches the structure indicated in regular expression exp.

If it does, the command extracts it from string and stores it in the matchvar variable. In regular expressions, you can specify the strings to extract as many as you want at any desired position. These strings will be stored in submatchvar variables in order.

For how to write a regular expression, see "15.1.4 Regular Expression".

Return Values

0:

Not matched.

1:

Matched.

Examples