INDEX(STRING, SUBSTRING, BACK)

Purpose

Returns the starting position of a substring within a string.

Class

Elemental function

Argument Type and Attributes

STRING
must be of type character.

SUBSTRING
must be of type character with the same kind type parameter as STRING.

BACK (optional)
must be of type logical.

Result Type and Attributes

Default integer.

Result Value

Examples

INDEX ('FORTRAN', 'R') has the value 3.

INDEX ('FORTRAN', 'R', BACK = .TRUE.) has the value 5.


Specific Name Argument Type Result Type Pass As Arg?
INDEX default character default integer yes (1)

Notes:

  1. When this specific name is passed as an argument, the procedure can only be referenced without the BACK optional argument.
IBM Copyright 2003