REReplace

Description

Returns string with a regular expression replaced with substring in the specified scope. This is a case-sensitive search.

Category

String functions

Syntax


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

See also

REFind, Replace, ReplaceList, REReplaceNoCase

Parameters

Parameter
Description
string
A string.
reg_expression
Regular expression to replace. Can include POSIX-specified character classes (for example, [:alpha:], [:digit:], [:upper:], and [:lower:]).
substring
String replacing reg_expression.
scope
Defines how to complete the replace operation:
  • ONE    Replace only the first occurrence (default).
  • ALL    Replace all occurrences.

Example

<!--- This example shows the use of REReplace --->

<html>

<head>

<title>REReplace Example</title>

</head>

<body bgcolor = silver>

<H3>REReplace Example</H3>

<P>The REReplace function returns <i>string</i> with a regular

expression replaced with <i>substring</i> in the specified scope. This

is a case-sensitive search.

<P>REReplace("CABARET","C|B","G","ALL"):  

<cfoutput>#REReplace("CABARET","C|B","G","ALL")#</cfoutput>

<P>REReplace("CABARET","[A-Z]","G","ALL"):  

<cfoutput>#REReplace("CABARET","[A-Z]","G","ALL")#</cfoutput>

<P>REReplace("I love jellies","jell(y|ies)","cookies"):

<cfoutput>#REReplace("I love jellies","jell(y|ies)","cookies")#

 </cfoutput>

<P>REReplace("I love jelly","jell(y|ies)","cookies"):

<cfoutput>#REReplace("I love jelly","jell(y|ies)","cookies")#</cfoutput>

</body>

</html> 



Banner.Novgorod.Ru