Chapter 2: ColdFusion Functions
499
Replace
Returns string with occurrences of substring1 being replaced with substring2 in the
specified scope.
See also
Find
,
ReplaceNoCase
,
ReplaceList
, and
REReplace
.
Syntax
Replace
(
string, substring1, substring2 [, scope ])
string
Any string.
substring1
String to be replaced.
substring2
String that should replace occurrences of substring1.
scope
Defines how to complete the replace operation:
•
ONE
— Replace only the first occurrence (default).
•
ALL
— Replace all occurrences.
Examples
<!--- This example shows the use of Replace --->
<HTML>
<HEAD>
<TITLE>
Replace Example
</TITLE>
</HEAD>
<BODY BGCOLOR=silver>
<H3>Replace Example</H3>
<P>The Replace function returns <I>string</I> with
<I>substring1</I> being replaced by <I>substring2</I> in
the specified scope. This is a case-sensitive search.
<CFIF IsDefined("FORM.MyString")>
<P>Your original string, <CFOUTPUT>#FORM.MyString#</CFOUTPUT>
<P>You wanted to replace the substring <CFOUTPUT>#FORM.MySubstring1#
</CFOUTPUT>
with the substring <CFOUTPUT>#FORM.MySubstring2#</CFOUTPUT>.
<P>The result: <CFOUTPUT>#Replace(FORM.myString,
FORM.MySubstring1, FORM.mySubString2)#</CFOUTPUT>
</CFIF>
...
Summary of Contents for COLDFUSION 4.5-CFML LANGUAGE
Page 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...
Page 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...
Page 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...
Page 336: ...312 CFMLLanguageReference CFIF BODY HTML...
Page 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...
Page 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...
Page 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...
Page 584: ...560 CFMLLanguageReference...
Page 594: ...570 CFMLLanguageReference...