System.Delete
Delphi
procedure Delete(var S: <string or dynamic array>; Index: Integer; Count: Integer);
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure | public | System.pas | System | System |
Description
Removes a substring from a string, or removes elements from a dynamic array and returns the modified array.
In Delphi code, Delete removes a substring of Count
characters from string or array S
, starting with S[Index]
. S
is a string-type variable. Index
and Count
are integer-type expressions.
If Index
is larger than the length of the string or array (or less than 1), no characters are deleted.
If Count
specifies more characters or array fields than remain starting at Index
, Delete removes the rest of the string or array. If Count
is less than or equal to 0, no characters are deleted.
- Note: Delete uses one-based array indexing even in platforms where the strings are zero-based.
Dynamic Array Example
var
A: array of integer;
begin
...
A:=[1,2,3,4];
Delete(A,1,2); //A will become [1,4]
...
end;
See Also