Top index Wirbel home

::rfind

string.rfind(s, int from, int to) - search for substring in string range from the end
string.rfind(s, int from) - search for substring in string tail from the end
string.rfind(s) - find substring in string

string.rfind(s, int from, int to) searches for a substring s in astring. Only astringfrom:to is being searched. The substring a must fit completely into that range. If the substring is found, the index of the last occurance is returned. Otherwise -1 is returned.

string.rfind(s, int from) is a conveniance variant of rfind that searches in astringfrom: -- from from until the end of the string. The index of the last occurance or s is returned, or -1 if s has not been found.

string.rfind(s) searches for s in astring. It returns the index (the offset from the beginning) of the last occurance of s, or -1 if s is not contained in astring.

Examples

"Piripiri".find("ri",0,8) == 6
"Piripiri".find("ri",3,5) == -1

"Haystack".find("stack") == 3
"Haystack".find("needle") == -1

See also

find, part_match