Delete

Delete elements (characters) from a string or dynamic array.

Declaration

Source position: system.fpd line 40

  procedure Delete(var S: string; const Index: Integer; 
                  const Count: Integer);
  procedure Delete(var A: DynArrayType; const Index: Integer; 
                  const Count: Integer);

Description

Delete removes Count characters from string S, starting at position Index. Index is 1-based. All characters after the deleted characters are shifted Count positions to the left, and the length of the string is adjusted.

For dynamic arrays, Delete removes Count elements from the array A, starting at position Index. Index is 0-based. All elements after the deleted elements are shifted Count positions to the left, and the length of the array is adjusted.

If the sum of Index and Count exceeds the length of the string or array, Delete removes the end of the string or array, starting at Index.

If Index is less than 1 or greater than the length of the string or array, or if Count is negative or zero, Delete does nothing.

See also

Name Description
Copy Copy part of a string.
Insert Insert one string or dynamic array in another.
Pos Search for substring in a string.

Example

Program Example15;
{ Program to demonstrate the Delete function. }
Var
  S : String;
begin
  S:='This is not easy !';
  Delete (S,9,4); { S:='This is easy !' }
end.