Delete a section of characters from a string System unit
 procedure Delete ( var Source : string; StartChar : Integer; Count : Integer ) ;
The Delete procedure deletes up to Count characters from the passed parameter Source string starting from position StartChar.
No error is produced if Count exceeds the remaining character count of Source.
The first character of a string is at position 1.
If the StartChar is before the first, or after the last character of Source, then no characters are deleted.

Delete(myString, 5, MaxInt);

  is equivalent to the better performing :

SetLength(myString, 4);
Related commands
Concat Concatenates one or more strings into one string
Copy Create a copy of part of a string or an array
Insert Insert a string into another 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
WrapText Add line feeds into a string to simulate word wrap
Trim Removes leading and trailing blanks from a string
TrimLeft Removes leading blanks from a string
TrimRight Removes trailing blanks from a string
 Author links

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : Deleting characters from the middle of a string
  Source : string;

  Source := '12345678';
  Delete(Source, 3, 4);    // Delete the 3rd, 4th, 5th and 6th characters
  ShowMessage('Source now : '+Source);
Show full unit code
   Source now : 1278
Delphi Programming Neil Moffatt 2002 - 2016. All rights reserved.  |  Home Page