notInCharClass function

int? notInCharClass(
  1. CharClass charClass,
  2. String string
)

Tests whether all characters of string are in the charClass. Returns null if all characters are in the charClass, otherwise the first index of string with a character not in charClass

Implementation

int? notInCharClass(CharClass charClass, String string) {
  int? rc;
  final members = BaseRandom.getCharClassMembers(charClass) ?? '';
  for (var ix = 0; ix < string.length; ix++) {
    if (!members.contains(string[ix])) {
      rc = ix;
      break;
    }
  }
  return rc;
}