Insert
Inserts a substring into another string at a specified position.
Method Signature
Insert(substring=[string], string=[string], position=[integer])
Arguments
Argument
Type
Required
Description
Default
substring
string
true
The string to insert.
string
string
true
position
integer
true
The position at which to insert the string.
Examples
Simple insert function example
To add substring on prefix of the given string
someString = " chrome browser";
result = insert( "Google", someString, 0 );
writeOutput( result );
Result: Google chrome browser
Simple insert function example with position
To add substring on suffix of the given string
someString = "New private mozilla fire";
length = len( someString );
writeOutput( insert( "fox", someString, length ) );
Result: New private mozilla firefox
Additional Examples
str = "I love ";
writeDump( insert( "boxlang", str, 7 ) ); // I love boxlang
// Member function
st = "Example";
writeDump( st.insert( " code", 7 ) );
// Example code
Related
Last updated
Was this helpful?