Returns the result of extracting the regular expression from the string, optionally with a substitution expression and a specified result if no match is found.Returns an empty string, or the string specified in
no_match
if the expression does not match. If the string specified was
none
, an empty string is returned.
The optional substitution expression is used to store groups that match the search expression. The first group is stored in
\1
, the second in
\2
, and so forth. For example:
A versioning string is of the form "Version 2.7.182 patch 69". To extract the patch number, the following function is used:
The expression
patch (\d+)
matches
patch 69
in the versioning string and it contains the first group matching
\1
which is
69
. If the versioning string was "Version 2.7.182 patch 69 patch 70" then the second group matching
\2
is
70
.
If the versioning string was "Version 2.7.182", the function would return "Unsupported."
acceptance of BMC’s
Terms of Use
. BMC, the BMC logo, and other BMC marks are assets of BMC Software, Inc. These trademarks are
registered
may be registered
in the U.S. and in other countries.