REReplaceNoCase

Description

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

Returns

  • If scope = "one": returns a string with the first occurrence of the regular expression replaced by the value of substring.
  • If scope = "all": returns a string with all occurrences of the regular expression replaced by the value of substring.
  • If the function finds no matches: returns a copy of the string, unchanged.

Category

String functions

Function syntax

REReplaceNoCase(string, reg_expression, substring [, scope ])

See also

REFindREFindNoCaseReplaceReplaceList

History

ColdFusion (2018 release) Update: Added the flag useJavaAsRegexEngine to Application.cfc. Enable this flag to use Java Regex as the default regex engine. For more information, see Application variables. For information on using Regular Expression using the flag, see Using Regular Expressions.

ColdFusion MX: Changed behavior: this function inserts the following special characters in regular expression replacement strings, to control case conversion: \u, \U, \l, \L, and \E. If any of these strings is present in a ColdFusion 5 application, insert a backslash before it (for example, change "\u" to "u").

Parameters

Parameter

Description

string

A string or a variable that contains one.

reg_expression

Regular expression to replace. For more information, see Using Regular Expressions in Functions in the Developing ColdFusion Applications.

substring

A string or a variable that contains one. Replaces reg_expression.

scope

  • one: replaces the first occurrence of the regular expression. Default.
  • all: replaces all occurrences of the regular expression.

Usage

For details on using regular expressions, see Using Regular Expressions in Functions in the Developing ColdFusion Applications.

Example

<cfscript>
    writeOutput(REReplace("CABARET","C|B","G","ALL") & "<br/>")
    writeOutput(REReplace("CABARET","C|B","G","ALL") & "<br/>")
    writeOutput(REReplace("CABARET","[A-Z]","G","ALL") & "<br/>")
    writeOutput(REReplace("CABARET","[A-Z]","G","ALL") & "<br/>")
    writeOutput(REReplace("I love jellies","jell(y|ies)","cookies") & "<br/>")
    writeOutput(REReplace("I love jellies","jell(y|ies)","cookies") & "<br/>")
    writeOutput(REReplace("I love jelly","jell(y|ies)","cookies") & "<br/>")
    writeOutput(REReplace("I love jelly","jell(y|ies)","cookies") & "<br/>")
</cfscript>

 Adobe

Get help faster and easier

New user?

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online