INDEX(STRING, SUBSTRING, BACK, KIND)

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.
Fortran 2003 begins KIND (optional)
must be a scalar integer constant expression. Fortran 2003 ends

Result type and attributes

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 
Note:
  •  1  When this specific name is passed as an argument, the procedure can only be referenced without the BACK and KIND optional argument.