POSIT: Finding the Beginning of a Substring

How to:

The POSIT function finds the starting position of a substring within a source string. For example, the starting position of the substring DUCT in the string PRODUCTION is 4. If the substring is not in the parent string, the function returns the value 0.


Top of page

x
Syntax: How to Find the Beginning of a Substring
POSIT(source_string, length, substring, sublength, output)

where:

source_string

Alphanumeric

Is the string to parse.

length

Integer

Is the number of characters in the source string. If this argument is less than or equal to 0, the function returns a 0.

substring

Alphanumeric

Is the substring whose position you want to find.

sublength

Integer

Is the number of characters in substring. If this argument is less than or equal to 0, or if it is greater than length, the function returns a 0.

output

Integer



Example: Finding the Position of a Letter

POSIT determines the position of the first capital letter I in LAST_NAME and stores the result in a column with the format I2:

POSIT(LAST_NAME, 15, 'I', 1, 'I2')

For STEVENS, the result is 0.

For SMITH, the result is 3.

For IRVING, the result is 1.


iWay Software