Description
The functx:index-of-match-first function returns an integer representing the first position of a substring that matches $pattern within $arg. If $arg does not match $pattern, the empty sequence is returned.
Arguments and Return Type| Name | Type | Description |
$arg |
xs:string? |
the string |
$pattern |
xs:string |
the pattern to match |
| return value |
xs:integer? |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for July 2004 - January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:index-of-match-first
( $arg as xs:string? ,
$pattern as xs:string ) as xs:integer? {
if (matches($arg,$pattern))
then string-length(tokenize($arg, $pattern)[1]) + 1
else ()
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function index-of-match-first
( $arg as xs:string? ,
$pattern as xs:string ) as xs:integer? {
if (fn:matches($arg,$pattern))
then fn:string-length(fn:tokenize($arg, $pattern)[1]) + 1
else ()
} |
Examples| XQuery Example | Results |
|---|
functx:index-of-match-first(
'abcdabcdabcd','abc')
|
1
|
functx:index-of-match-first(
'abcdabcdabcd','bcd')
|
2
|
functx:index-of-match-first('a1234','\d')
|
2
|
functx:index-of-match-first('abc abc','\s')
|
4
|
functx:index-of-match-first('abc abc','z')
|
()
|
See AlsoHistory |
|