FINDCHARS

The FINDCHARS function returns the character position of the beginning of a specified group of characters within a text expression.

Tip:

When you are using a multibyte character set, you can use the FINDBYTES function instead of the FINDCHARS function.

Return Value

INTEGER

Syntax

FINDCHARS(text-expressioncharacters [starting-pos [LINENUM]])

Parameters

text-expression

The text expression in which you are searching for the specified characters. Text-expression can be a multiline value. In this case, FINDCHARS searches all lines for the specified characters. The match must be exact, including a match of upper- and lowercase characters.

FINDCHARS accepts TEXT values and NTEXT values as arguments. When only one argument is NTEXT, then FINDCHARS automatically converts the other argument to NTEXT before performing the function operation

characters

The group of characters for which you are searching. When characters is a multiline value, FINDCHARS ignores all lines except the first one.

When characters is not found in text-expression, FINDCHARS returns zero. When the group of characters occurs more than once, FINDCHARS returns the position of its first occurrence.

starting-pos

An INTEGER expression that specifies the character position where the search in text-exp should start. The default is at position 1 (the first character) in text-exp.

LINENUM

Specifies that FINDCHARS should return the line number instead of the character position of the beginning of the specified text.

Examples

Example 7-96 Finding the Starting Position of a Character Group

This example shows how to find the starting position of various groups of characters in the literal TEXT value hellotherejoe.

The statement

SHOW FINDCHARS('hellotherejoe', 'joe')

produces the following output.

11

The statement

SHOW FINDCHARS('hellotherejoe', 'al')

produces the following output.

0