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:
$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.
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 Note: In extended mode, blank space data characters in the pattern are ignored, except when they are escaped or inside a character class. Characters between an unescaped # outside a character class and the next new line character, inclusive, are also ignored. |
match_regex/4 example
'[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].