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

344
Views
How to escape * in regex password pattern

I use validate.js for form validation and have a password pattern where I would like to allow only one of the following special characters: -!@_#+

Password pattern is as below:

 password1: {
  pattern:/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[-!@_#+])(?=.{8,})/
},

However, when I enter *, $ or % character as password input no error message is given. Any help would be appreciated. Thank you.

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

0

You are not really limiting the input options of the user, your pattern says: From the starting position of string, check if it is followed by a lower case letters, then check if it is followed by a uppercase letters, followed by numbers and then some symbols.

There is nothing to limit the users input. Since .* will match any char that is not a line terminator(\n, \r etc).

You should try something like this: /^([-\w!@#+]+){8,}$/
Here \w mathces a-z, A-Z, 0-9 and underscore.

Test regex here: https://regex101.com/r/TINm56/1

enter image description here

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!