Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

269
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda