strstr method

int strstr(
  1. String haystack,
  2. String needle
)

Finds the first occurrence of the substring needle in the string haystack.

Returns the index of the substring, or -1 if the substring is not found.

Implementation

int strstr(String haystack, String needle) {
  if (needle.isEmpty) return 0;
  return haystack.indexOf(needle);
}