GLBasic User Manual

Main sections


pos% = REVINSTR(haystack$, needle$, start%=-1)

Finds a substring needle$ in a string haystack$ in reverse direction. The parameter start% specifies the start position in haystack$. A value of -1 starts the search at the end of haystack$. Specifying 0 would only search at the very beginning of the haystack$.

LOCAL haystack$ = "the quick brown fox jumps over the lazy dog"
LOCAL pos%
// Returns 31
pos = REVINSTR(haystack$, "the")
STDOUT "pos1: "+pos+"\n"

// Returns 0
pos = REVINSTR(haystack$, "the", 16)
STDOUT "pos2: "+pos+"\n"

// Returns 41
pos = REVINSTR(haystack$, "g")
STDOUT "g: "+pos+"\n"


See also...