Description |
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.
|
| Notes | 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 |
|
Download this web site as a Windows program.
|
|
|
|
Example code : Deleting characters from the middle of a string | var
Source : string;
begin
Source := '12345678';
Delete(Source, 3, 4);  // Delete the 3rd, 4th, 5th and 6th characters
ShowMessage('Source now : '+Source);
end;
| Show full unit code | Source now : 1278 |
|
|