LASTPOS (Last Position)

The LASTPOS function returns the position of the last occurrence of one string, needle, in another, haystack.

Read syntax diagramSkip visual syntax diagram LASTPOS( needle , haystack ,start )

LASTPOS returns 0 if needle is the null string or is not found. By default the search starts at the last character of haystack and scans backward. You can override this by specifying start, the point at which the backward scan starts. start must be a positive whole number and defaults to LENGTH(haystack) if larger than that value or omitted. See also the POS function, POS (Position).

Examples

LASTPOS(' ','abc def ghi')      ->    8
LASTPOS(' ','abcdefghi')        ->    0
LASTPOS('xy','efgxyz')          ->    4
LASTPOS(' ','abc def ghi',7)    ->    4