The below function worked with the WString library in IDE 0018. Is there an equivalant function in the string handling included in the 0021 IDE? The StringSubstring (bottom link) function does not seem to support the string search the old string.contains has.
The indexOf method is overloaded with char and String inputs for the thing to search for. It appears to be a replacement for contains. The indexOf method returns where in the string the substring occurs, or -1 if the substring does not exist.
bool Contains( String s, String search)
{
int max = s.length() - search.length(); // the searchstring has to fit in the other one
for (int i=0; i<= max; i++)
{
if (s.substring(i) == search) return true; // or i
}
return false; //or -1
}
variation return the position i >= 0 if found , and -1 if not => functiontype should be int
update: Paul you beat me ! IndexOf is the way to go.