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 TypeName | 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 |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:replace-beginning" as="xs:string"
xmlns:functx="http://www.functx.com">
<xsl:param name="arg" as="xs:string?"/>
<xsl:param name="pattern" as="xs:string"/>
<xsl:param name="replacement" as="xs:string"/>
<xsl:sequence select="
replace($arg, concat('^.*?', $pattern), $replacement)
"/>
</xsl:function>
|
ExamplesXPath 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 |
Recommended Reading:
|