简体   繁体   中英

Regular Expression to check for letter, number, and symbol

I am trying to validate a password in Javascript and require that it has a letter (upper or lowercase), a number, and a symbol. This is the Regex I have

/(?=.*\d)(?=.*[a-zA-Z])(?=.*\W)/

This does not seem to be working. Any suggestions?

You are missing a couple of asterisks.

/(?=.*\\d)(?=.*[a-zA-Z])(?=.*\\W)/

edit: The question was edited. The code now works as is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM