Currently, I use the following regular expression for the user to enter a password
^\w{8,16}$
Now as I understand, \w only allows a-z, A-Z, 0-9, and the _ character (underscore). I want to do allow any character, but the length is to be between 8 and 16. How do I get about doing it?
Firstly, use a word count for what you need rather than regex.
If you really must, then
.{8,16}should work, the.matches a single char, no matter what it is.EDIT:
To preempt your next question which will surely be, what is a good password validation regular expression, you might want to check out some of these blogs:
http://nilangshah.wordpress.com/2007/06/26/password-validation-via-regular-expression/
http://www.zorched.net/2009/05/08/password-strength-validation-with-regular-expressions/
OR just look up ‘password validation stackoverflow’ on google