Name
[2.0] matches()
Determines whether a given string matches a given regular expression.
Syntax
xs:booleanmatches($input as xs:string?,$pattern as xs:string)xs:booleanmatches($input as xs:string?,$pattern as xs:string,$flags as xs:string)
Inputs
An input string and a regular expression. The matches() function also supports an
optional string defining flags that modify how the regular
expression is processed.
Outputs
true if the string
matches the regular expression; false otherwise.
Regular expressions are extremely powerful, so there are a number of details about how they work:
If
$inputis the empty sequence, it is interpreted as a zero-length string. Thematches()function can still returntruein this situation. For example,matches((),'.?')istrue, as ismatches('', '.?').Regular expression matching does not use collations; the characters’ Unicode code points are compared. Cases in which different characters are considered equal in the world’s languages are not taken into account.
Unless you use the
^(start of line) or$(end of line) characters as anchors in your regular expression, a string is considered a match if any part of it matches the regular expression.Unlike regular expressions used in the
<xsl:analyze-string>element, curly braces ({and}) are not doubled. (Curly braces used inside theregexattribute of<xsl:analyze-string>must be doubled so they aren’t interpreted as attribute value templates.)The
$flagsparameter modifies how the regular expression is processed. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access