Intel® Fortran Compiler 16.0 User and Reference Guide

MBINDEX (W*S)

NLS Function: Performs the same function as INDEX except that the strings manipulated can contain multibyte characters.

Module

USE IFNLS

result = MBINDEX (string,substring[,back])

string

(Input) CHARACTER*(*). String to be searched for the presence of substring. Can contain multibyte characters.

substring

(Input) CHARACTER*(*). Substring whose position within string is to be determined. Can contain multibyte characters.

back

(Input; optional) LOGICAL(4). If specified, determines direction of the search. If back is .FALSE. or is omitted, the search starts at the beginning of string and moves toward the end. If back is .TRUE., the search starts end of string and moves toward the beginning.

Results

The result type is INTEGER(4). If back is omitted or is .FALSE., it returns the leftmost position in string that contains the start of substring. If back is .TRUE., it returns the rightmost position in string that contains the start of substring. If string does not contain substring, it returns 0. If substring occurs more than once, it returns the starting position of the first occurrence ("first" is determined by the presence and value of back).

The position returned is a byte index, not a character index because of the confounding case of multibyte characters. As an example, if a substring which is a single multi-byte character matches the second multibyte character in a string consisting of two two-byte multi-byte characters the position is 3, not 2.

See Also