The matches() function
Smartsite 7.4 - ...
The matches() XPath 2.0 function returns true if the supplied string matches a given regular expression.
| XML |
|
|---|---|
boolean fn:matches(input, string pattern) |
|
Parameters:
- input: a node reference or string literal.
- string pattern: pattern to match (regular expression).
Example
| XML |
|
|---|---|
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<head>
<title>Example</title>
<xf:model>
<xf:instance>
<data xmlns="">
<string>abracadabra</string>
</data>
</xf:instance>
</xf:model>
</head>
<body>
<xf:group>
<xf:output value="fn:matches(string, 'bra')" />
<xf:output value="fn:matches('abracadabra', '^a.*a$')" />
<xf:output value="fn:matches(string, '^bra')" />
</xf:group>
</body>
</html>
|
|
The result will be:
true
true
false
true
false
Namespace
This function is available within the XPath 2.0 namespace (http://www.w3.org/2005/xpath-functions).