STRPOS

The STRPOS function finds the first occurrence of a substring within an object string. If Search_String occurs in Expression , STRPOS returns the character position of the match, otherwise it returns -1.

Calling Sequence

Result = STRPOS( Expression, Search String [, Pos] )

Arguments

Expression

The expression in which to search for the substring. If this argument is not a string, it is converted using IDL's default formatting rules. If Expression is an array, the result is an array with the same structure, where each element contains the position of the substring within the corresponding element Expression . If Expression is the null string, STRPOS returns the value -1.

Search_String

The substring to be searched for within Expression . If this argument is not a string, it is converted using IDL's default formatting rules. If Search_String is the null string, STRPOS returns the smaller of Pos or one less than the length of Expression .

Pos

The character position at which the search is begun. If Pos is omitted, the search begins at the first character (character position 0). If Pos is less than zero, zero is used for the starting position.

Example

Find the position of the string "fun" within the string "IDL is fun" and print the result by entering:

PRINT, STRPOS('IDL is fun', 'fun')

IDL prints:

   7

See Also

RSTRPOS , STRMID , STRPUT , STRTRIM