Description
Replaces occurrences of substring1 with substring2, in the specified scope. The search is case-insensitive.
Returns
A copy of the string, after making replacements.
Category
Function syntax
1 | ReplaceNoCase (string, substring, callback, [ scope ]) |
See also
Find, REFind, Replace, ReplaceList, REReplace
History
ColdFusion (2021 release): Added the parameter start.
ColdFusion (2016 release): Introduced named parameters.
Parameter |
Description |
---|---|
string |
A string (or variable that contains one) within which to replace substring. |
substring |
String (or variable that contains one) to replace, if found. |
callback |
Function to replace string. Parameters are:
|
scope |
|
start | Position to start searching in the string (starts at 1). |
1 2 3 4 5 6 | < cfscript > myStr= "hAppy app application apply appreciate appreciation Apprentice" ; outStr = replacenocase ( myStr, "app" , function (transform, position, original) { return UCase (transform); } , "all" ); writeoutput ( "Output:" & outStr); </ cfscript > |
1 2 3 4 5 6 7 8 9 10 11 12 13 | < cfscript > // ReplaceNoCase ( String string, String substring, Object replacement, String scope, int start ) string= "The quick brown fox jumped over the lazy cow." substring= "ow" replacement= "aze" scope= "ALL" start= len ( "The quick brown" ) myoutput= replacenocase (string,substring,replacement, scope, start) writeOutput (myoutput & "" ) // scope= "ONE" myoutput1= replacenocase (string,substring,replacement, "ONE" , start) writeOutput (myoutput1 & "" ) </ cfscript > |
1 2 3 4 5 6 7 8 9 10 | < cfscript > // Define the callback function callback=(regexp,position,original)=>{ retString = regExp. reverse ()& "aze" return retString } baseStr= "The quick brown fox jumped over the lazy cow." writeOutput ( replaceNoCase (baseStr, "ow" , callback, "all" , len ( "The quick bro" )) & "" ) writeOutput ( replaceNoCase (baseStr, "ow" , callback, "all" , len ( "The quick brown" )) & "" ) </ cfscript > |