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

264
Views
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 answers
Answer question

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 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!