strpbrk method

int strpbrk(
  1. String str1,
  2. String str2
)

Finds the first character in the string str1 that matches any character specified in str2.

Returns the index of the character, or -1 if no such character exists.

Implementation

int strpbrk(String str1, String str2) {
  for (int i = 0; i < str1.length; i++) {
    if (str2.contains(str1[i])) {
      return i;
    }
  }
  return -1;
}