aha364636
aha364636

Reputation: 363

Password.match isn't working with special characters

I want to use this regex to check the strength of my password. But it doesn't really work with this line of code, which I found on an other site. The / causes some problems. How do I have to write it for this list.
I need this list of characters in my regex:()[]{}?!$%&/=*+~,.;:<>-_

if (password.match(/([(,),[,],{,},?,!,$,%,&,/,=,*,+,~,])/))

Upvotes: 0

Views: 73

Answers (1)

hjpotter92
hjpotter92

Reputation: 80639

Escape. Escape using backslash (\).

/([()[\]{}?!$%&\/=*+~])/
      ^^       ^^ escaped literals

Note that ] also needed to be escaped.

Upvotes: 1

Related Questions