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
AnsiReplaceStr Replaces a part of one string with another
Concat Concatenates one or more strings into one string
Copy Create a copy of part of a string or an array
Delete Delete a section of characters from a string
Move Copy bytes of data from a source to a destination
StringOfChar Creates a string with one character repeated many times
StringReplace Replace one or more substrings found within a string
StuffString Replaces a part of one string with another
WrapText Add line feeds into a string to simulate word wrap
 Author links

 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 2002 - 2020. All rights reserved.  |  Home Page