replaceNoCase

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

replaceNoCase(string, substring1, callback [, scope]) → returns string

Member Function Syntax

string.replaceNoCase(substring1, callback[, scope])

replaceNoCase Argument Reference

string string
Required

A string (or variable that contains one) within which to replace substring

substring1 string
Required

A string (or variable that contains one) to replace, if found.

callback any
Required

String to replace substring1 with. As of CF 2018+ you can also pass a callback function in this argument function(transform, position, original).

scope string

* one: Replace the first occurrence (default)
* all: Replace all occurrences
Values:
  • one
  • all

start numeric
Default: 1

CF 2021+ Position to start searching in the string.

Examples
Sample code invoking the replaceNoCase function

getVal = replaceNoCase("ColdFUsion", "u", "a");
writeDump(getVal);

Expected Result: Expected Result: ColdFasion

<cfset getVal = replaceNoCase("ColdFusiOn", "O", "a", "ALL")>
<cfdump var="#getVal#">

Expected Result: Expected Result: CaldFusian


Fork me on GitHub