Description
The functx:replace-beginning function replaces the beginning of $arg (up to and including the first area that matches $pattern) with $replacement. If no area matches the pattern, no replacement is made.
Arguments and Return Type| Name | Type | Description |
$arg |
xs:string? |
the entire string to change |
$pattern |
xs:string |
the pattern of characters to replace up to |
$replacement |
xs:string |
the replacement string |
| return value |
xs:string |
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:replace-beginning
( $arg as xs:string? ,
$pattern as xs:string ,
$replacement as xs:string ) as xs:string {
replace($arg, concat('^.*?', $pattern), $replacement)
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function replace-beginning
( $arg as xs:string? ,
$pattern as xs:string ,
$replacement as xs:string ) as xs:string {
fn:replace($arg, fn:concat('^.*?', $pattern), $replacement)
} |
Examples| XQuery Example | Results |
|---|
functx:replace-beginning('abc-def', '-', 'xxx')
|
xxxdef
|
functx:replace-beginning('abc-def', '-', '')
|
def
|
functx:replace-beginning(
'---abc', '[a-z]', 'x')
|
xbc
|
functx:replace-beginning(
'2004-12-05', '-', '2005-')
|
2005-12-05
|
See AlsoHistory |
|