match_regex/4—match a string with a regular expression and retrieve  all fields from it


The match_regex/4 function matches a string with a regular expression and retrieve  all fields from it. The syntax for this function is as follows:

match_regex($STR,$REGEX,$OPTS,$FLDS)
$FLDS=match_regex($STR,$REGEX,$OPTS)

match_regex/4 arguments

Argument

Mode

Type

Description

$STR

Input

STRING

Specifies the string to be matched

$REGEX

Input

STRING

Specifies the regular expression to match to the string

$OPTS

Input

STRING

Specifies the options for how the regular expression engine operates

$FLDS

Output

LIST_OF STRING

Retrieved fields

Use the match_regex/4 to match a string $STR with regular expression $REGEX applying options from $OPTS and to collect retrieved fields in $FLDS.

Note

The regular expression $REGEX must be compliant with the Perl Compatible Regular Expression specification. For a specification, see http://perldoc.perl.org/perlre.html.

The options argument can be either an empty string or a sequence of any of the following option indicators:

Option

Description

i

Perform case insensitive string comparison

m

Multi-line mode

s

A dot matches any character, including new line

x

Extended mode (see below)

match_regex/4 example

match_regex('2007 02 04 mcell: RULES: xyz',
'[0-9]* [0-9]* [0-9]* ([^:]*): ([^:]*): .*','',$FLDS);

The input string, which could be part of a trace, matches the regular expression. The two fields are collected in $FLDS as [mcell,RULES].

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*