Skip to content

Instantly share code, notes, and snippets.

@sergeevabc
Created October 28, 2014 03:46
Show Gist options
  • Save sergeevabc/57008f2528599b781da0 to your computer and use it in GitHub Desktop.
Save sergeevabc/57008f2528599b781da0 to your computer and use it in GitHub Desktop.
Validate string against password policy via regex
// Rules: At leasst 1 uppercase, 1 lowercase, 1 digit, 1 special char from z85 alphabet
// Test: http://regex101.com/r/yP9aU6/1
function validateResult(string) {
var regex = (/^(?=\S*?\w)(?=\S*?\d)(?=\S*?[.\-:+=^!\/*?&<>()\[\]{}@%$#])[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.\-:+=^!/*?&<>()\[\]{}@%$#]+$/gm);
return regex.test(string);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment