Last active
July 27, 2021 09:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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