replace

Use the replace function to replace all occurrences of a fragment in a text with alternative text. The search is performed case-sensitive.

 replace ( haystack; needle; replacement )

This function returns a value of type TEXT.

The function has three parameters:

  1. haystack, type TEXT. The text that the search is performed on.
  2. needle, type TEXT. The fragment that is searched for.
  3. replacement, type TEXT. The alternative text that is used to replace the needle text.

The result of the search function is the input with all occurrences of needle replaced by replacement. Overlapping results are not considered for replacement.

Input is always converted to Unicode Normalization Form C (NFC). Tabs, paragraph breaks, and line breaks are handled as characters. Other word processor content, such as layout switches and graphical objects, is stripped before the comparison. Paragraph breaks, and line breaks are considered equal for comparison purposes.

Example

replace ("The Quick Brown Fox"; "o"; "O") returns "The Quick BrOwn FOx"

replace ("The Quick Brown Fox"; "O"; "o") returns "The Quick Brown Fox"

replace ("XXX"; "XX"; "aX") returns "aXX" (not "aaX" )