Inserts a substring in a string after a specified character position. Prepends the substring if position is equal to 0.
Insert(substring, string, position)
Parameter |
Description |
---|---|
substring |
String to insert |
string |
String into which to inserted |
position |
Integer that indicates the character position in string at which to insert substring |
<!--- 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> ...