Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
Strong Password validation doesn't detect forward slash

I have the following regex for testing a strong password:

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d!$\/%@]{6,20}$/

Rules:

  • alphanumeric with special characters $/%@
  • min 1 number
  • min 1 small
  • min 1 capital
  • 6-20 length
  • min 1 special character $/%@

My question is mostly about the last rule of minimum 1 special character when that character is a forward slash.

The following code, for special character @, returns TRUE as expected:

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d!$/%@]{6,20}$/.test("Test@2")

But the following code, for forward slash, does NOT:

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d!$/%@]{6,20}$/.test("Test/2")

I also tried to escape both the regex and the test string forward slash with / but that does not seem to return TRUE

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

My mistake was in the first validation of the special characters. The working solution is:

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!$\/%@])[A-Za-z\d!$\/%@]{6,20}$/
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!