Miscellaneous 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 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 |
%eval(<string>)
Evaluates the string as an expansion, and returns the result. The main difference between using this expansion and just using %{…} is that the string being evaluated can be dynamically changed.
if (User-Name == "bob") {
request.Tmp-String-0 := "User-Name"
} else {
request.Tmp-String-0 := "not bob!"
}
reply.Reply-Message := "%eval(request.Tmp-String-0}"
User-Name == bobbob
User-Name == not bobnot bob!