match_regex/3—match a string with a regular expression
The match_regex/3 function matches a string with a regular expression. The syntax for this function is as follows:
match_regex/3 arguments
Argument | Mode | Type | Description |
---|---|---|---|
$STR | Input | STRING | Specifies the string to be matched |
$REGEX | Input | STRING | Specifies the regular expression to match with the string |
$OPTS | Input | STRING | Specifies the options for how the regular expression engine operates |
Use the match_regex/3 to match a string $STR with regular expression $REGEX applying options specified in $OPTS.
The value of the $OPTS 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. |
The call of match_regex/3 will succeed if the string matches the regular expression and fail otherwise.
match_regex/3 example
'[0-9]* [0-9]* [0-9]* [^:]*: [^:]*: .*','');
The input string, which could be part of a trace, matches the regular expression.