NexJ Logo

Replace()

Finds and replaces the specified string of text with another string. This function takes three string values as arguments and returns a string value. The returned string will have each instance of the matching text replaced by the specified string.

Syntax

Replace(<source_text>, <pattern>, <replacement_text>)

Input

source_text

string, null

The text to search within.

pattern

string

The text pattern to match and replace within the source text. The text pattern can be a standard string or a regular expression.

replacement_text

string

The text to replace the matched text with.

Output

string

Examples

  • The expression Replace("The quick brown fox", "fox", "dog") returns "The quick brown dog".
  • The expression Replace("The quick brown fox", "f([a-z])x", "d$1g") returns  "The quick brown dog".