Position

Returns the starting position of the specified occurrence of searchString in text.

Format 

Position ( text ; searchString ; start ; occurrence )

Parameters 

text - any text expression or text field.

searchString - any text expression or text field representing the text you want to find.

start - any numeric expression, or field containing a number, representing the number of characters from the start of the text string at which to begin the search. A start value of 1 or less begins the search from the first character of the text string.

occurrence - any numeric expression or field containing a number, representing which instance of the text string you want to find. The scan begins at the start value and, if occurrence is positive, continues toward the end of the text string; if occurrence is negative, the scan continues toward the beginning of the text string. A zero value for occurrence is invalid and returns a result of zero.

Data type returned 

number

Originated in version 

6.0 or earlier

Description 

This function is not case sensitive. If searchString isn’t contained in text or if there was no specified occurrence, zero is returned.

Example 1 

Position ( "Mississippi" ; "iss" ; 1 ; 1 ) returns 2.

Position ( "Mississippi" ; "iss" ; 1 ; 2 ) returns 5.

Position ( "Mississippi" ; "iss" ; 3 ; 1 ) returns 5.

Example 2 

Left ( Name ; Position ( Name ; " " ; 1 ; 1 ) - 1 ) returns William, when Name is a text field that contains William Smith.

Example 3 

Right ( Name ; Length ( Name ) - Position ( Name ; " " ; Length ( Name ) ; - 1 ) ) returns Smith.