home contribute faq download

FunctX XQuery Functions

functx:get-matches

Return the matching regions of a string

Google
Webxqueryfunctions.com

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

NameTypeDescription
$string xs:string? the string to split
$regex xs:string the pattern
return value xs:string*

XQuery Function Declaration

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)
 } ;

Examples

XQuery ExampleResults
functx:get-matches(
   'abc123def', '\d+')
"123"
functx:get-matches(
   'abc123def', '\d')
("1","2","3")
functx:get-matches(
   'abc123def', '[a-z]{2}')
("ab","de")

Depends On

functx:get-matches-and-non-matchesSplits a string into matching and non-matching regions

History

Published OnLast UpdatedContributor(s)
2006-08-232007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XQuery Services

Recommended Reading:

XQuery