INDEX(STRING, SUBSTRING, BACK, KIND)

Purpose

Returns the starting position of a substring within a string.

Class

Elemental function

Argument type and attributes

STRING
An INTENT(IN) CHARACTER
SUBSTRING
An INTENT(IN) CHARACTER with the same kind type parameter as STRING.
BACK (optional)
An INTENT(IN) LOGICAL
Fortran 2003 begins KIND (optional)
An INTENT(IN) INTEGER scalar. The actual argument corresponding to KIND must be a 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.