SearchLastSubstring (open)
Find the last occurrence of a substring
Syntax
// Core function, no LOADLIB necessary
INTEGER FUNCTION SearchLastSubstring(STRING text, STRING search, INTEGER start)
Parameters
STRING text
String to search in
STRING search
String to search for
INTEGER start
The byte position to start searching. Note that characters in UNICODE(UTF-8) are sometimes made up from more bytes.
Return value
INTEGER
Starting byte position of the last occurence, or -1 if the string was not found
Description
Searchsubstring does a case-sensitive search in a string for the last occurence of a substring.
Examples
// returns 3
INTEGER example1 := SearchLastSubstring("aaaa", "a");
// returns 4
INTEGER example2 := SearchLastSubstring("ababab", "ab");
// returns -1
INTEGER example3 := SearchLastSubstring("abcdef", "g");
// returns -1
INTEGER example4 := SearchLastSubstring("abcdef", "A");
// returns 2
INTEGER example5 := SearchLastSubstring("ababab", "ab", 4);
// returns -1
INTEGER example6 := SearchLastSubstring("ababab", "ab", 0);