Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

345
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda