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 Type| Name | Type | Description |
$string |
xs:string? |
the string to split |
$regex |
xs:string |
the pattern |
| return value |
xs:string* |
XQuery Function Declaration| XQuery Syntax for April 2005 - January 2007 (1.0): |
|---|
declare 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)
} ; | | XQuery Syntax for July 2004: |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:get-matches
( $string as xs:string? ,
$regex as xs:string ) as xs:string* {
for $match in
functx:get-matches-and-non-matches($string,$regex)/self::match
return string($match)
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function get-matches
( $string as xs:string? ,
$regex as xs:string ) as xs:string* {
for $match in
functx:get-matches-and-non-matches($string,$regex)/self::match
return fn:string($match)
} |
Examples| XQuery 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 |
|