Insert a string into another string System unit
 procedure Insert(const InsertStr string; var TargetStr string; Position Integer);
The Insert procedure inserts one string, InsertStr into another string, TargetStr at the given Position.
The TargetStr string characters from the Position character are moved right to make way for the InsertStr string.
The length of TargetStr is now the sum of the length of the two strings.
To insert into the start of TargetStr, set Position to 1 or less.
To append to the end of TargetStr, set Position after the last character of TargetStr.
The first character of a string is at position 1

Arrays start at index 0.
Related commands
AnsiReplaceStrReplaces a part of one string with another
ConcatConcatenates one or more strings into one string
CopyCreate a copy of part of a string or an array
DeleteDelete a section of characters from a string
MoveCopy bytes of data from a source to a destination
StringOfCharCreates a string with one character repeated many times
StringReplaceReplace one or more substrings found within a string
StuffStringReplaces a part of one string with another
WrapTextAdd line feeds into a string to simulate word wrap
 Download this web site as a Windows program.

Example code : Inserting into the middle of a string
  Target : string;
  Target := '12345678';
  Insert('-+-', Target, 3);
  ShowMessage('Target : '+Target);
Show full unit code
  Target : 12-+-345678
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page