replace

Replaces occurrences of substring1 in a string with substring2,
in a specified scope. The search is case-sensitive. Function returns original string with replacements made.

replace(String, substring1, substring2 [, scope]) → returns String

Argument Reference for the replace function

String

Required: Yes
String to search

substring1

Required: Yes
Substring to find within string

substring2

Required: Yes
Substring to replace substring1 with

scope

Required: No
Default: one
* one: replace the first occurrence
* all: replace all occurrences Values:
  • one
  • all

Examples sample code invoking the replace function


Script Syntax

getVal = replace("ColdFUsion", "U", "u"); 
 writeDump(getVal);

Expected Result: Expected Result: ColdFusion


Tag Syntax

getVal1 = replace("COldFusiOn", "O", "o", "ONE"); 
 writeDump(getVal1);

Expected Result: Expected Result: ColdFusiOn


Fork me on GitHub