# 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>
    ...