reversePosIndex

reversePosIndex(substr: String;
                index:  Integer): Integer;

The reversePosIndex method of the String primitive type returns the position of the last occurrence of the substring specified in the substr parameter, in a string formed from the first character of the receiving string up to (and including) the character position specified in the index parameter.

The character search is case-sensitive.

The value of the index parameter cannot exceed the length of the receiving string.

The following example shows the use of the reversePosIndex method.

vars
    stringValue : String;
    count       : Integer;
begin
    stringValue := "car->taxi->bus->train";
    count := stringValue.length;
    while count > 0 do
        count := stringValue.reversePosIndex('->', count);
        write count;
        count := count - 1;
    endwhile;
    // Outputs 15
    // Outputs 10
    // Outputs 4
    // Outputs 0
end;

This method returns zero (0) if the specified substring is not found.