Loading TOC...


   $input as xs:string?,
   $pattern as xs:string,
   $replacement as xs:string,
   [$flags as xs:string]
) as xs:string?


Returns a string constructed by replacing the specified $pattern on the $input string with the specified $replacement string.

input The string to start with.
pattern The regular expression pattern to match. If the pattern does not match the $input string, the function will return the $input string unchanged.
replacement The regular expression pattern to replace the $pattern with. It can also be a capture expression (for more details, see http://www.w3.org/TR/xpath-functions/#func-replace).
flags The flag representing how to interpret the regular expression. One of "s", "m", "i", or "x", as defined in http://www.w3.org/TR/xpath-functions/#flags.


fn:replace("this is a string", "this", "that")

=> that is a string

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.