re: Daily Challenge #32 - Hide Phone Numbers VIEW POST

FULL DISCUSSION
 

JavaScript

function obfuscatePhone(number) {
  if (!/^\d{3}-\d{3}-\d{4}$/.test(number)) return false;
  return number.replace(/\d(?=(?:-?\d){0,5}$)/g, 'X');
}

But it could be any language that supports look-aheads in regular expressions 😉

code of conduct - report abuse