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
$input
is the empty sequence, it is interpreted as a zero-length string. Thematches()
function can still returntrue
in 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 theregex
attribute of<xsl:analyze-
string>
must be doubled so they aren’t interpreted as attribute value templates.)The
$flags
parameter modifies how the regular expression is processed. ...
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.