String.LastIndexOfAny

Syntax

LastIndexOfAny(Value: String; [StartIndex: Integer = -1;] [Count: Integer = -1]): Integer;

Parameters

Value. The substring, which should be searched for in the string.

StartIndex. The position, starting from which the search is executed.

Count. The number of places, in which the search is executed.

Description

The LastOndexOfAny method returns the index of the last occurrence of any of the substring characters passed in the Value parameter in the current string.

Comments

The search starts from the StartIndex place and continues in the reverse direction (from right to left) in the Count places. By default, the StartIndex and Count parameters have the -1 value, in this case the search goes from the end of strings and continues to the beginning until any of the characters of the Value substring is found, or the string character is reached.

If the specified substring is not found in the source string, the method returns -1. Characters are case-sensitive.

Example

Sub UserProc;
Var
    s, s1, s2: String;
    i, i1: Integer;
Begin
    s := "ab";
    s1 := "adnfbegdswa";
    s2 := "dfsdfewqawr";
    i := S1.LastIndexOfAny(s);
    i1 := S2.LastIndexOfAny(s);
End Sub UserProc;

After executing the example the "i" variable will contain the value "10", and the "i1" variable will contain the "9" value.

See also:

String