user1772951
user1772951

Reputation: 19

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?

Upvotes: 0

Views: 249

Answers (1)

ericjustusson
ericjustusson

Reputation: 46

You are missing a couple of asterisks.

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

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

Upvotes: 3

Related Questions