RSTRPOS

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 rstrpos.pro in the lib subdirectory of the IDL distribution.

Calling Sequence

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

Arguments

Expression

The expression string in which to search for the substring.

Search_String

The substring to be searched for within Expression .

Pos

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

Example

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

STRPOS