UCSearchLastSubstring (open)

Find the last occurrence of a UTF-8 substring

Syntax

// Core function, no LOADLIB necessary

INTEGER FUNCTION UCSearchLastSubstring(STRING text, STRING search, INTEGER start)

Parameters

STRING text

String to search in

STRING search

String to search for

INTEGER start

The character position to start searching

Return value

INTEGER

Starting character position of the last occurence, or -1 if the string was not found

Description

UCSearchLastSubstring does a case-sensitive search in a string for the last occurence of a substring.

Examples

// returns 3
INTEGER example1 := UCSearchLastSubstring("aaaa", "a");

// returns 4
INTEGER example2 := UCSearchLastSubstring("ababab", "ab");

// returns -1
INTEGER example3 := UCSearchLastSubstring("abcdef", "g");

// returns -1
INTEGER example4 := UCSearchLastSubstring("abcdef", "A");

// returns 2
INTEGER example5 := UCSearchLastSubstring("ababab", "ab", 4);

// returns -1
INTEGER example6 := UCSearchLastSubstring("ababab", "ab", 0);