Skip to content

TStrings.LastIndexOf

Return the index of the last occurrence of a string.

Declaration

Source position: classesh.inc line 1144

public 
function LastIndexOf(const S: string; aStart: Integer) : Integer
                    ;  virtual;  overload; overload;

function LastIndexOf(const S: string) : Integer;  overload; overload;

Description

LastIndexOf returns the index of the last occurrence of the string S. If aStart is specified, the search starts at the specified index in the list (it defaults to Count-1). If aStart is negative, it is used as an offset to Count, i.e. aCount equal to -1 will start the search at Count-1.

If aStart is larger than Count-1 it will be capped to Count-1.

See also

Name Description
IndexOf Find a string in the list and return its position.
IndexOfObject Finds an object in the list and returns its index.