Description
The functx:get-matches function splits a string into parts that match and returns each of those parts in a sequence.
The regular expression cannot match a zero-length string, or an error is raised. Overlapping matches do not appear separately as matches.
Arguments and Return TypeName | Type | Description |
$string |
xs:string? |
the string to split |
$regex |
xs:string |
the pattern |
return value |
xs:string* |
XQuery Function Declarationdeclare namespace functx = "http://www.functx.com";
declare function functx:get-matches
( $string as xs:string? ,
$regex as xs:string ) as xs:string* {
functx:get-matches-and-non-matches($string,$regex)/
string(self::match)
} ; |
ExamplesXQuery Example | Results |
---|
functx:get-matches(
'abc123def', '\d+') |
"123" |
functx:get-matches(
'abc123def', '\d') |
("1","2","3") |
functx:get-matches(
'abc123def', '[a-z]{2}') |
("ab","de") |
Depends OnHistory |
Recommended Reading:
|