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

131
Vistas
Regex to allow only any character from a-z both lower and upper, any number and special characters . -_ only

I have a requirement where we need to add find out regex pattern where user can enter below combinations only.

  1. It should be any character from a-z both lower and upper,
  2. Any number from 0-9
  3. Special characters . -_ only.

we have used below regex pattern..

/^(?=.*?[a-zA-Z0-9.-_])+$/

Can someone please help on this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

A - has different meanings in a character class depending on its position

At the end or at the start it's a literal: [._-] contains the three literals ., _ and -

Somewhere else, it's a range: [.-_] is a range from . to _.

You can use 4 regexes to check the strings

function check(str) {
  return /^[a-zA-Z0-9._-]+$/.test(str) && /[a-zA-Z]/.test(str) && /[0-9]/.test(str) && /[._-]/.test(str);
}

const str1 = 'aA5.-_';
console.log(check(str1));
const str2 = 'aA5';
console.log(check(str2));
const str3 = 'aA5.-_+';
console.log(check(str3));

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