rindex()

Return the last occurrence of one text string within another.

Syntax

rindex(text,string)

Parameter

Parameter

Definition

text

text to be examined for occurrences of string The text can be a text string enclosed in double quotation marks, or one or more PSL commands that produce text.

string

one or more characters whose last occurrence is being identified within text

Description

The rindex() function returns the position of the last occurrence of string in text or 0 if string does not occur in text. Positions in string are numbered starting from one and are indicated as integers.

Example

The following is an example of the rindex() function:

sentence = "The quick brown fox jumped over the lazy dogs";
findme = "he";
print("The last occurrence is in position ",rindex(sentence,findme));

This example produces the following output:

The last occurrence is in position 34
Was this page helpful? Yes No Submitting... Thank you

Comments