I’m using the following Regex to ensure that a password only has alphabetic and numeric characters.
if(! reFind("^[[:alnum:][:punct:]]", this.password)) {
this.addError(property="Password", message="Password must contain only letters, numbers, or punctuation marks.");
}
If I add a copyright © character to the beginning of the word, the reFind blocks it; if I add it to the end of the word, it goes through. So ©abcd does not go through, while abcd© does.
I want to make sure that I only allow alphanumeric and punctuation characters in my passwords.
Your regular expression just ensures that the first character is alphanumeric and/or punctuation. You want to ensure that every character is alphanumeric and/or punctuation. You can use either of these:
(Note: these also differ from yours in that they allow a zero-length password. I figure that that’s O.K., since you’ll want to give a different error message in that case.)