The RSTRPOS function finds the last occurrence of a substring within an object string (the STRPOS function finds the first occurrence of a substring). If the substring is found in the expression, RSTRPOS returns the character position of the match, otherwise it returns -1.

This routine is written in the IDL language. Its source code can be found in the file in the lib subdirectory of the IDL distribution.

Calling Sequence

Result = RSTRPOS( Expression, Search_String [, Pos] )



The expression string in which to search for the substring.


The substring to be searched for within Expression .


The character position before which the search is begun. If Pos is omitted, the search begins at the last character of Expression .


exp = 'Holy smokes, Batman!' ; Define the expression.

pos = RSTRPOS(exp, 'smokes') ; Find the position of a substring.

PRINT, pos ; Print the substring's position.

IDL prints:

5 ; Substring begins at position 5 (the sixth character).

See Also