let regex = /(^d{6})|(d{3}$)/gm;
n = n.toString();
n = n.replace(regex,'#');
return '#####' + n + "##"
This is my regex but it returns #5225#
not the expected result which is ######5225###
.
let regex = /(^d{6})|(d{3}$)/gm;
n = n.toString();
n = n.replace(regex,'#');
return '#####' + n + "##"
This is my regex but it returns #5225#
not the expected result which is ######5225###
.
2
Answers
just you string slice, remove the first 6 and last 3 and return the result with additional
#
before and afterUse a replacer function and use repeat with the length of the match.
or using substring