Whatever message this page gives is out now! Go check it out!
ReplaceNoCase(string, searchstring, replacestring|obj [, scope ][,start])Parameter | Description |
string | A string (or variable that contains one) within which to replace substring. |
searchstring | 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). |
<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><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 & "<br/>")
// scope="ONE"
myoutput1=replacenocase(string,substring,replacement, "ONE", start)
writeOutput(myoutput1 & "<br/>")
</cfscript><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")) & "<br>")
writeOutput(replaceNoCase(baseStr, "ow", callback, "all", len("The quick brown")) & "<br>")
</cfscript>