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

256
Vistas
I'm working with JS, I know the use of replace method,Can you explain this specific code => /.(?=.{4})/g in the below function?
function maskify(cc) {
  return cc.replace(/.(?=.{4})/g, "#");
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is regex here /.(?=.{4})/

Any character followed by any character four times.

enter image description here

function maskify(cc) {
  return cc.replace(/.(?=.{4})/g, "#");
}

console.log(maskify("Awesome"));

If any character is followed by four characters except newline then it will replace it with #

a is followed by weso, replace a with #

w is followed by esom, replace w with #

e is followed by some, replace e with #

After e there is no character which is follwed by 4 characters, so it won't replace it with #

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