Whatever message this page gives is out now! Go check it out!

ReplaceNoCase

Last update:
May 18, 2026

Description

Replaces occurrences of string with searchstring, in the specified scope. The search is case-insensitive.

Returns

A copy of the string, after making replacements.

Category

Function syntax

ReplaceNoCase(string, searchstring, replacestring|obj [, scope ][,start])

See also

History

  • ColdFusion (2021 release): Added the parameter start.
  • ColdFusion (2016 release): Introduced named parameters.

Parameters

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:
  • transform
  • position
  • original
scope
  • one: replaces the first occurrence (default).
  • all: replaces all occurrences.
start
Position to start searching in the string (starts at 1).

Example

<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>

Example 2

<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>

Output

The quick brown fox jumped over the lazy caze.

The quick brown fox jumped over the lazy caze.

Example 3

<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>

Output

The quick brWOazen fox jumped over the lazy cWOaze.

The quick brown fox jumped over the lazy cWOaze.

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page