Skip to content

XQuery matches Function

Use the XQuery matches function to check if a string matches a regular expression and return true or false based on pattern matching.

XQuery matches Function

The matches function returns true if the input matches with the provided regular expression; otherwise false.

Syntax

matches($input, $regex)

Input Parameters

  • $input is the input string.
  • $regex is the regular expression.

Example

XQuery Expressionxquery
let $input := 'Tutorial Reference'
return (matches($input, 'Hello') =  true(),
matches($input, 'T.* R.*') =  true()
)
Outputxml
false
true
Navigation