linus72982 Posted March 4, 2011 Share Posted March 4, 2011 I am building a new site for forums that has a high population of old people and they wouldn't appreciate me not allowing their simple passwords, so I search and search and everything I found on google requires complexity. So, if anyone can help with a regex that does the following, I'd appreciate it: 1. Can contain only letters, numbers, and symbols (just the normal symbols, no unicode or slashes, etc) 2. Cannot contain spaces 3. Must be 8-16 characters in length That's it, no other complexity required. Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/229623-regex-for-a-simple-password/ Share on other sites More sharing options...
.josh Posted March 5, 2011 Share Posted March 5, 2011 Well, since you didn't really fully define what you consider to be "normal" symbols, this regex will only accept letters, numbers and any of the symbols above the numbers on your keyboard. if (preg_match('~^[a-z0-9!@#\$%\^&\*\(\)]{8,16}$~i',$password)) { // valid } else { // invalid } Link to comment https://forums.phpfreaks.com/topic/229623-regex-for-a-simple-password/#findComment-1183086 Share on other sites More sharing options...
linus72982 Posted March 5, 2011 Author Share Posted March 5, 2011 Thanks, and yes, I meant just the symbols on the number keys. I'll try it out. Link to comment https://forums.phpfreaks.com/topic/229623-regex-for-a-simple-password/#findComment-1183101 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.