Skip to content

Instantly share code, notes, and snippets.

@ArefMozafari
Last active July 27, 2021 09:58
Show Gist options
  • Save ArefMozafari/4af4d4a64ac83a07ba2a3f16bc01e30a to your computer and use it in GitHub Desktop.
Save ArefMozafari/4af4d4a64ac83a07ba2a3f16bc01e30a to your computer and use it in GitHub Desktop.
Flutter/Dart - Regex that checks if password has at least specialCount special character matches
//Checks if password has at least specialCount special character matches
bool hasMinSpecialChar(String password, int specialCount) {
String pattern =
r"^(.*?[$&+,\:;/=?@#|'<>.^*()%!-]){" + specialCount.toString() + ",}";
return password.contains(new RegExp(pattern));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment