Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

MBINDEX

NLS Function: Performs the same function as INDEX except that the strings manipulated can contain multibyte characters. This routine is only available for Windows.

Module

USE IFNLS

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

string

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

substring

(Input) CHARACTER*(*). Is a 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. For example, if a substring that is a single multibyte 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