ec_pcre_match

March 26, 2020 Contributors

Name

ec_pcre_match — perform a regular expression match

Synopsis

ec_pcre_match { string } { pattern }

Description

ec_pcre_match performs a regular expression match and returns a stringlist containing the matched strings. The zeroth element of the stringlist consists of the part of the string that matched the whole given pattern, the first element corresponds to the first captured subpattern, the second element to the second captured subpattern, and so on.

$email = "[email protected]";
($a, $b, $c) = ec_pcre_match $email "(.*)@(.*)\.com";

# $a is "[email protected]", $b is "foo" and $c is "bar"
ec_log "the string matched is ${a}, $1 is ${b}, $2 is ${c}.";