$position

Locates the first occurrence of a pattern in a character string.

Syntax

$position(source,pattern)

Parameters

source

a character string, or an expression that evaluates to a character string

pattern

a character string, or an expression that evaluates to a character string

Return Value

Number, being the position of the first character in source that matches the first character of pattern, when pattern is found in source.

Comments

$position returns a number that identifies the start position of pattern in source. If pattern is not found in source, $position returns 0.

If either source or pattern is not of a character data type, it is converted to a character string before the operation begins. If source is of data type ALPHA or VARALPHA, the operation is case-insensitive; otherwise, the operation is case-sensitive.

Example

$position(var1,"ab")

Evaluates to 4 if var1 is "defabc".

$position("abcdef","zz")

Evaluates to 0.

find all Customers where $position(Comments, "overdrawn") > 0

Determines if the word overdrawn appears in the Comments field for any one of your Customers.

 

Related Topics