Previous Topic: Usage Notes for the DATE FunctionNext Topic: INDEX Function


FIND Function

REXX code that uses the FIND function invokes the TSO/E REXX version of the function when running under TSO/E.

Note: You can use the FIND function in OPS/REXX or AOF rules.

FIND has the following format:

var = FIND(string,phrase,startingposition)

The FIND function searches string for the first occurrence of a blank-delimited phrase (which may contain one word) and returns the word number of the first word of the phrase in the string. During the search, multiple blanks between words in either strings or phrases are treated as single blanks. If the phrase is not found, the FIND function returns 0.

FIND(y,x) is equivalent to the function call WORDPOS(x,y) in TSO/E REXX. In general, use the WORDPOS function instead of FIND. For more information about WORDPOS, see your TSO/E REXX documentation.

Note: The OPS/REXX FIND function supports a startingposition argument. The standard REXX FIND function does not support startingposition.

Examples: FIND

In these examples, the numbers on the right are the word numbers returned:

Sample Statement

Value Returned

var = FIND('now is the time', 'the')

3

var = FIND('now is the time', 'The')

0

var = FIND('now is the time', 'is the')

2

var = FIND('now is the time', 'is the')

2

var = FIND('now is the time', 'is time')

0

var = FIND('To be or not to be', 'be')

2

var = FIND('To be or not to be', 'be', 3)

6