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

152
Vistas
Regex to replace digits with a character x times the match's length

Got the regex (?<!a|\d)[0-9]{6,} to match any digits with 6 in length or more, but that do not start with \ or digits.

Previously, I used I used [0-9] in replace("[0-9]", "x"), and it would replace 111 with xxx.

But now with the new formula replace("(?<!a|\d)[0-9]{6,}", "x") it just replaces with one x.

How can I make it so it continues the old behavior? I tried to use a function but it did not seem to work very well (using Zoho mail which uses weird JS language)

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

0

Use a function as the replacement. It can then repeat the character the same number of times as the length of the match.

console.log('123456'.replace(/(?<!a|\d)[0-9]{6,}/g, match => "x".repeat(match.length)));

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