reReplaceNoCase

Uses a regular expression to search a string for a string
pattern and replace it with another. The search is
case-insensitive.

reReplaceNoCase(String, reg_expression, substring[, scope]) → returns string

Member Function Syntax

string.reReplaceNoCase(reg_expression, substring[, scope])

Argument Reference

String string
Required

A string or a variable that contains one

reg_expression string
Required

Regular expression to replace.

substring string
Required

A string or a variable that contains one. Replaces
reg_expression

scope string

* one: Replace the first occurrence of the regular
expression. Default.
* all: Replace all occurrences of the regular expression.
Values:
  • one
  • all

Examples
Sample code invoking the reReplaceNoCase function

This example strips out all characters except a-z and 0-9.

reReplaceNoCase("test 123!", "[^a-z0-9]", "", "ALL")

Expected Result: test123

Uses a back reference: \1 to extract the pattern contained within the parenthesis.

reReplaceNoCase("123abc456", "[0-9]+([a-z]+)[0-9]+", "\1")

Expected Result: abc

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub