ReplaceNoCase()
Replaces occurrences of substring1 with substring2, in the specified scope.
The search is case-insensitive.
ReplaceNoCase( string=string, substring=any, replacement=string, scope=string );
Returns: String
| Argument | Description | Default |
|---|---|---|
|
string
string,
required
|
edit
A string (or variable that contains one) within which to replace substring. |
|
|
substring
any,
required
|
edit
Substring for which to search. Optionally pass a Struct with key/value pairs to do a replace all Alias: substring1 |
|
|
replacement
string,
optional
|
edit
Substring with which to replace the found matches. This arg is required if the substring1 arg is a string Alias: substring2 |
|
|
scope
string,
optional
|
edit
scope for the execution:
|
one |
Examples
editwriteDump(replaceNoCase("xxabcxxabcxx","ABC","def"));
writeDump(replaceNoCase("xxabcxxabcxx","abc","def","All"));
writeDump(replaceNoCase("xxabcxxabcxx","AbC","def","hans"));
writeDump(replaceNoCase("a.b.c.d",".","-","all"));
test = "camelcase CaMeLcAsE CAMELCASE";
test2 = replaceNoCase(test, "camelcase", "CamelCase", "all");
writeDump(test2);
writeDump(var=
replaceNoCase("One string, two strings, Three strings",
{"one": 1, "Two": 2, "three": 3, "string": "txt", "text": "string"}),
label="replaceNoCase via a struct"
); // struct keys need to be quoted
See also
- Strings
- Replace()
- string.replaceNoCase()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)