<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.replace.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.replace</api:function-name><api:suggest>fn.replace</api:suggest><api:suggest>fn</api:suggest><api:suggest>replace</api:suggest><api:function-link mode="xquery" fullname="fn:replace">/apidoc/8.0/fn:replace.xml</api:function-link><api:function mode="javascript" name="replace" type="builtin" lib="fn" category="StringBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.replace"><api:summary>
Returns a string constructed by replacing the specified $pattern
on the $input string with the specified $replacement string.
</api:summary><api:params><api:param name="input" type="xs:string?"><api:param-description>
  The string to start with.
  </api:param-description><api:param-name>input</api:param-name><api:param-type>String?</api:param-type></api:param><api:param name="pattern" type="xs:string"><api:param-description>
  The regular expression pattern to match.  If the pattern does not match the
  $input string, the function will return the $input string unchanged.
  </api:param-description><api:param-name>pattern</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="replacement" type="xs:string"><api:param-description>
  The regular expression pattern to replace the $pattern with.  It can also
  be a capture expression (for more details, see
  <a href="http://www.w3.org/TR/xpath-functions/#func-replace" target="_blank" xmlns="http://www.w3.org/1999/xhtml">http://www.w3.org/TR/xpath-functions/#func-replace</a>).
  </api:param-description><api:param-name>replacement</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="flags" type="xs:string" optional="true"><api:param-description>
  The flag representing how to interpret the regular expression. One of
  "s", "m", "i", or "x", as defined in
  <a href="http://www.w3.org/TR/xpath-functions/#flags" xmlns="http://www.w3.org/1999/xhtml">http://www.w3.org/TR/xpath-functions/#flags</a>.
  </api:param-description><api:param-name>flags</api:param-name><api:param-type>String</api:param-type></api:param></api:params><api:return>String?</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn.replace("this is a string", "this", "that");

=&gt; that is a string
</pre>
</api:example></api:function></api:function-page>