insert

Inserts a substring in a string after a specified character
position. If position = 0, prefixes the substring to the
string.

insert(substring, String, position) → returns string

Argument Reference

substring string
Required

A string to insert

String string
Required

A string, which to insert substring

position numeric
Required

Substring add after this position value in given string

Examples
Sample code invoking the insert function

To add substring on prefix of the given string

someString = ' chrome browser';
result = insert('Google', someString, 0);
writeOutput(result);

Expected Result: Google chrome browser

To add substring on suffix of the given string

someString = 'New private mozilla fire';
length = len(someString);
writeOutput(insert('fox', someString, length));

Expected Result: New private mozilla firefox

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub