## 9.3.136 SCAN (STRING, SET [, BACK] [, KIND])

Description: | Scans a string for any character in a set of characters.
Class: | Elemental function; Generic
Arguments: | STRING | Must be of type character.
| SET | Must be of type character with the same kind parameter as STRING.
| BACK (opt) | Must be of type logical.
| KIND (opt) | Must be a scalar integer initialization expression.
Results: | The result is of type integer. If KIND is present, the kind parameter of the result is that specified by KIND; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the result value in the kind of the result, the result is undefined. If BACK is omitted (or is present with the value false) and STRING has at least one character that is in SET, the value of the result is the position of the leftmost character of STRING that is in SET. If BACK is present with the value true and STRING has at least one character that is in SET, the value of the result is the position of the rightmost character of STRING that is in SET. If no character of STRING is in SET or the length of STRING or SET is zero, the value of the result is zero.

Examples

SCAN ('ASTRING', 'ST') has the value 2.

SCAN ('ASTRING', 'ST', BACK=.TRUE.) has the value 3.

SCAN ('ASTRING', 'CD') has the value zero.

Previous Page Next Page Table of Contents