Top index Wirbel home

::find

string.find(s, int from, int to) - find substring in string range
string.find(s, int from) - find substring in string tail
string.find(s) - find substring in string

string.find(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 first occurance is returned. Otherwise -1 is returned.

string.find(s, int from) is a conveniance variant of find that searches in astringfrom: -- from from until the end of the string.

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

Examples

 "Haystack".find("sta",2,8) == 3
 "Haystack".find("sta",4,8) == -1

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

See also

part_match, rfind