TSubstringList.RemoveItem Method

function RemoveItem(const S: string; const Direction: TDirection): Integer; overload;

Deletes the first (FromBeginning) or last (FromEnd) item equal to S.

#NameDescription
1S

The text, every text kind.

2Direction

FromBeginning: the first equal item; FromEnd: the last.

Returns: Integer - Its index, or -1 when there is none.

Examples

Removing the last match.

uses Substr, System.Types;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(4);
    try
        List.Add('a');
        List.Add('b');
        List.Add('a');
        Assert(List.RemoveItem('a', FromEnd) = 2);
        Assert((List.Count = 2) and (List[0] = 'a') and (List[1] = 'b'));
    finally
        List.Free;
    end;
end;
See Also: TSubstringList.Remove