INDEX — Position of a substring within a string¶
- INDEX()¶
Returns the position of the start of the first occurrence of string
SUBSTRINGas a substring inSTRING, counting from one. IfSUBSTRINGis not present inSTRING, zero is returned. If theBACKargument is present and true, the return value is the start of the last occurrence rather than the first.- Parameters
STRING – Shall be a scalar
CHARACTER, withINTENT(IN)SUBSTRING – Shall be a scalar
CHARACTER, withINTENT(IN)BACK – (Optional) Shall be a scalar
LOGICAL, withINTENT(IN)KIND – (Optional) An
INTEGERinitialization expression indicating the kind parameter of the result.
- Returns
The return value is of type
INTEGERand of kindKIND. IfKINDis absent, the return value is of default integer kind.
Standard:Fortran 77 and later, with
KINDargument Fortran 2003 and laterClass:Elemental function
Syntax:RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])
Specific names:Name
Argument
Return type
Standard
INDEX(STRING, SUBSTRING)CHARACTERINTEGER(4)Fortran 77 and later
See also:SCAN, VERIFY