RushRed
RushRed

Reputation: 75

How do I add all special characters without typing them all out in this regex?

I'm very new to regex and was wondering if there was a quick way for me to include all the special characters in this regexp without tediously typing them all out?

  # Need 1 char of A-Z, a-z, 0-9, special character and 12 characters min
  config.password_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!"'@#$&* £])(?=.{12,})/

Upvotes: 0

Views: 76

Answers (1)

Thomas Ayoub
Thomas Ayoub

Reputation: 29431

The closer you can get without having issues with new lines in a password is:

[^\w\s]

which means not a whitespace nor a char in the range a-z nor a digit

Upvotes: 1

Related Questions