ezeio2:scriptref:strfind

This is an old revision of the document!


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"
  • ezeio2/scriptref/strfind.1560624743.txt.gz
  • Last modified: 2019-06-15 18:52
  • by andreh