Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

346
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda