The first replace finds the last 6 digits, with or without trailing separators.
The resulting match undergoes another replace call to substitute any digits for X's.
The first expression can also be relaxed to allow any separators: /(\d[^\d]?){6}$/, or even any number of separators: /(\d[^\d]*){6}$/.
JavaScript:
The first
replace
finds the last 6 digits, with or without trailing separators.The resulting match undergoes another
replace
call to substitute any digits for X's.The first expression can also be relaxed to allow any separators:
/(\d[^\d]?){6}$/
, or even any number of separators:/(\d[^\d]*){6}$/
.This is neat
Winner