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

160
Views
javascript regex [-_.] no es el primer carácter

No quiero la primera letra de estos caracteres _-. Usado pero puede usarse entre caracteres

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

0

Si [a-zA-Z0-9-. ] es el rango permitido de caracteres, debe estar presente de 1 a 10 veces y no puede comenzar con - o . entonces no necesitas mirar alrededor.

Puede hacer coincidir el primer carácter [a-zA-Z0-9 ] y repetir el rango totalmente permitido 0-9 veces.

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

Vea una demostración de expresiones regulares .

Si también se permite un guión bajo, puede acortar el patrón usando \w :

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

0

Modifiqué con algunas herramientas en línea y lo siguiente debería funcionar bien:

 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}`); }); }

También recomiendo usar el sitio web regex101.com si desea jugar con Javscript regex.

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!