Skip to content

llInsertString

string llInsertString(string TargetVariable, integer Position, string SourceVariable)

Inserts SourceVariable into TargetVariable at Position, and returns the result.

Inserts SourceVariable into TargetVariable at Position and returns the result. Note this does not alter TargetVariable.

Parameters
TargetVariable (string)
Position (integer)
SourceVariable (string)
llInsertString("input", 2, "put out") // returns "input output"

Unlike llGetSubString and llDeleteSubString, llInsertString does not accept negative indices for position counting. Use this helper function to add that capability:

string insertString(string destination, integer position, string str) {
if (position < 0)
if ((position += llStringLength(destination)) < 0)
position = 0;
return llInsertString(destination, position, str);
}

This wrapper allows you to use negative numbers as the position parameter, where -1 refers to the last position in the string.

  • Unlike llGetSubString and llDeleteSubString, llInsertString does not accept negative indices for position counting
  • The position parameter is zero-indexed (first character is at position 0)
  • Does not modify the original strings; returns a new string with the insertion
  • SplitLine - Insert newline escape codes at certain positions of a string