insert
Description
Inserts a substring in a string after a specified character position. If position=0, prefixes the substring to the string.
Categories
Related
Syntax
Insert(substring, string, position)
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| position | Integer or variable; position in string after which to insert substring. | ||
| string | A string or a variable that contains one. String into which to insert substring. | ||
| substring | A string or a variable that contains one. String to insert. |
Returns
A string.
Example
<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>
This string only has #Len(MyString)# characters; therefore,
you cannot insert the substring #FORM.mySubString# at position
#FORM.insertPosition#.
</cfoutput>
</cfif>
<cfelse>
<cfoutput>
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>
</cfif>