Chapter 2: ColdFusion Functions
383
Insert
Inserts a substring in a string after a specified character position. Prepends the
substring if position is equal to 0.
See also
RemoveChars
and
Len
.
Syntax
Insert
(
substring, string, position)
substring
String to be inserted.
string
String to be inserted into.
position
Integer that indicates the character position in string where the substring will be
inserted.
Examples
<!--- This example shows the use of Insert --->
<HTML>
<HEAD>
<TITLE>
Insert Example
</TITLE>
</HEAD>
<BODY BGCOLOR=silver>
<H3>Insert Example</H3>
<CFIF IsDefined("FORM.myString")>
<!--- if the position is longer than the length of
the string, err --->
<CFIF FORM.insertPosition GT Len(MyString)>
<CFOUTPUT>
<P>This string only has #Len(MyString)#
characters; therefore, you cannot insert the substring
#FORM.mySubString# at position #FORM.insertPosition#.
</CFOUTPUT>
<CFELSE>
<CFOUTPUT>
<P>You inserted the substring #FORM.MySubstring# into the
string #FORM.MyString#, resulting in the following
string:
<BR>#Insert(FORM.MySubString, FORM.myString, FORM.insertposition)#
</CFOUTPUT>
...
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...