====== StrFind ====== {{tag>string}} ''int StrFind(str s, str what)'' ===== Description ===== Returns the position of the first occurence of what in s. If the string is not present, returns -1. To search for the **last** occurence, use [[StrRFind]]. ===== Examples ===== StrFind("abcdefabc", "def") -> 3 StrFind("abcdefabc", "abc") -> 0 // First occurence StrFind("abcdef", "xyz") -> -1 // Not found StrFind("abcABCabc", "ABC") -> 3 // Case-insensitive StrFind("ab", "abc") -> -1 // Not found StrFind("", "abc") -> -1 // Not found int index = StrFind(s, "keyword"); if (index != -1) print(s:"Found the keyword at position ", d:index); else print(s:"Keyword not found"); ===== See also ===== * [[StrRFind]] * [[StrFindFrom]] * [[StrRFindFrom]]