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

162
Vistas
javascript regex [-_.] not first character

I do not want the first letter of these characters _-. Used but can use between characters

'(^[a-zA-Z0-9-_. ]*$){1,10}'
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If [a-zA-Z0-9-. ] is the allowed range of characters, should be present 1-10 times and can not start with - or . then you don't need lookarounds.

You can match the first character [a-zA-Z0-9 ] and repeat the fully allowed range 0-9 times.

^[a-zA-Z0-9][a-zA-Z0-9. -]{0,9}$

See a regex demo.

If an underscore is also allowed, you could shorten the pattern using \w:

^[a-zA-Z0-9][\w. -]{0,9}$
about 4 years ago · Juan Pablo Isaza Denunciar

0

I tweaked with some tools online and the follwoing do should do the job fine:

const regex = /^[^\_\-\.]{1}(.)*/gm;
const str = `.awdawd`;
let m;

while ((m = regex.exec(str)) !== null) {
    // This is necessary to avoid infinite loops with zero-width matches
    if (m.index === regex.lastIndex) {
        regex.lastIndex++;
    }
    
    // The result can be accessed through the `m`-variable.
    m.forEach((match, groupIndex) => {
        console.log(`Found match, group ${groupIndex}: ${match}`);
    });
}

I also recommend using the website regex101.com if you wanted to play around with the Javscript regex.

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