This is an old revision of the document!
Script reference
strfind( string[], sub[], ignorecase=false, index=0 )
Searches a string for a substring
Description
strfind( const string[], const sub[], bool:ignorecase=false, index=0 )
Search the haystack string
for a needle sub
. Optionally ignore case and start at an offset in the haystack.
Parameters
string | String to be searched (the haystack) |
sub | The string we're looking for (the needle) |
ignorecase (optional) | If set to true, the search will ignore case |
index (optional) | Start at an offset different than the start of the haystack string |
Return value
Returns the offset of sub
in string
if successful.
Returns -1 if no occurrence of sub
was found in string
.
Example usage
new s{20} = "CatDogAnt"; strdel(s, 3, 6); // returns 1 // s is now "CatAnt"