Regular Expression Expansions
%regex.search(pattern, string)
Performs a regular expression search on string, using pattern. If
there are subgroups in pattern, the subgroups are available via a
subsequent %regex.match(). Each regular expression search (or
=~ operator) clears and refreshes the list of
matches in %regex.match().
This function is the same as using %{string =~ /pattern/}. However,
this function is included for completeness.
%regex.match(0)..%regex.match(32)
%regex.match(0) expands to the portion of the subject that matched the last regular
expression evaluated. %regex.match(1)..%regex.match(32) expand to the contents of any capture
groups in the pattern.
Every time a regular expression is evaluated, whether it matches or not, the numbered capture group values will be cleared.
%regex.match(<named capture group>}
Return named subcapture value from the last regular expression evaluated.
Results of named capture groups are available using the %regex.match(<named capture
group>} expansion. They will also be accessible using the numbered expansions
described above.
Every time a regular expression is evaluated, whether it matches or not, the named capture group values will be cleared.
|
This expansion is only available if the server is built with libpcre2.
Use the output of ... Debug : regex-pcre2 : yes Debug : regex-posix : no Debug : regex-posix-extended : no Debug : regex-binsafe : yes ... Debug : pcre2 : 10.33 (2019-04-16) - retrieved at build time |
if (%regex.search("(j)(i(m))", User-Name)) {
reply.Reply-Message := %regex.match(2)
}
User-Name == "jim"im
if (%regex.search("(?<first>b.*)b", User-Name)) {
reply.Reply-Message := %regex.match("first")
}
User-Name == "bob"bo