@ReplaceSubstring (Formula Language)

Replaces specific words or phrases in a string with new words or phrases that you specify. Case sensitive.

Syntax

@ReplaceSubstring( sourceList ; fromList ; toList )

Parameters

sourceList

Text or text list. The string whose contents you want to modify.

fromList

Text or text list. A list containing the words or phrases that you want to replace.

toList

Text or text list. A list containing the replacement words or phrases.

Return value

newSourceList

Text or text list. The sourceList, with any values from fromList replaced by the corresponding value in toList. If none of the values in fromList matched the values in sourceList, then sourceList is returned unaltered.

Usage

If more strings are specified in the fromList than the toList, the extra strings in fromList are replaced with the last string in toList. Extra strings in toList are ignored. If no matches are found, @ReplaceSubstring returns the unmodified sourceList.

If a list is specified for fromList, each subsequent list item is scanned against the resulting sourceList, with prior list item substitutions performed.

For example:

@ReplaceSubstring("first";"first":"second";"second":"third") 

returns third.

First, @ReplaceSubstring substitutes "second" for "first" from the first list item in fromList. The resulting sourceList is now "second." The function substitutes "third" for "second" from the second list item in fromList.

Tip: Use @ReplaceSubString to remove carriage returns from text by replacing them with " " or "."

Examples

  1. This example returns "I hate apples".
    @ReplaceSubstring( "I like apples" ; "like" ; "hate" )
  2. This example returns "I hate peaches".
    @ReplaceSubstring( "I like apples" ; "like" : "apples" ; "hate" : "peaches")
  3. This example replaces all carriage returns in the Description field's text with blank spaces.
    @ReplaceSubString(Description;@Newline;" ")