# fn:matches - XPath XQuery Reference

Returns true if the supplied string matches a given regular expression.deterministiccontext-independentfocus-independentThe effect of calling the first version of this function (omitting the argument
               $flags) is the same as the effect of calling the second version with the
               $flags argument set to a zero-length string. Flags are defined in
               .If $input is the empty sequence, it is interpreted as the zero-length
            string.The function returns true if $input or some substring of
               $input matches the regular expression supplied as $pattern.
            Otherwise, the function returns false. The matching rules are influenced by
            the value of $flags if present. fn:matches("abracadabra", "bra")true()fn:matches("abracadabra", "^a.*a$")true()fn:matches("abracadabra", "^bra")false()Given the source document:
<poem author="Wilhelm Busch">
Kaum hat dies der Hahn gesehen,
Fängt er auch schon an zu krähen:
Kikeriki! Kikikerikih!!
Tak, tak, tak! - da kommen sie.
</poem>the following function calls produce the following results, with the
                  poem element as the context node:fn:matches($poem, "Kaum.*krähen")false()fn:matches($poem, "Kaum.*krähen", "s")true()fn:matches($poem, "^Kaum.*gesehen,$", "m")true()fn:matches($poem, "^Kaum.*gesehen,$")false()fn:matches($poem, "kiki", "i")true()A dynamic error is raised  if the value of
               $pattern is invalid according to the rules described in . A dynamic error is raised  if the value of
               $flags is invalid according to the rules described in . Unless the metacharacters ^ and $ are used as anchors, the
            string is considered to match the pattern if any substring matches the pattern. But if
            anchors are used, the anchors must match the start/end of the string (in string mode),
            or the start/end of a line (in multi-line mode). This is different from the behavior of patterns in , where
            regular expressions are implicitly anchored.Regular expression matching is defined on the basis of Unicode code points; it takes no
            account of collations.