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