fn:replace

Replaces sequences of characters within a string that match a given regular expression.

replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string) ➔ xs:string

Arguments

 

$input

xs:string?

The input string, parts of which are to be replaced

 

$pattern

xs:string

The regular expression matching parts of the string that are to be replaced

 

$replacement

xs:string

The replacement string

Result

xs:string

replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string, $flags as xs:string) ➔ xs:string

Arguments

 

$input

xs:string?

The input string, parts of which are to be replaced

 

$pattern

xs:string

The regular expression matching parts of the string that are to be replaced

 

$replacement

xs:string

The replacement string

 

$flags

xs:string

Flags controlling how the regular expression is interpreted

Result

xs:string

Namespace

http://www.w3.org/2005/xpath-functions

Links to W3C specifications

XPath 3.1 Functions and Operators

Saxon availability

Available in XPath 2.0, XSLT 2.0, XQuery 1.0, and later versions. Available in all Saxon editions.

Notes on the Saxon implementation

Saxon 9.3 introduces support for the q flag, and for XPath 3.0 regular expression enhancements, provided XPath 3.0 is enabled.

Saxon supports extended syntax for the flags argument: see the matches() function for details.

See also:

fn:matches()