I have a array of string and the patterns like #number-number
If the # and single digit number before by hyphen then replace # and add 0
If the # and two or more digit number before by hyphen then replace remove #
I got stuck and how to do in javascript
In #number,
if # and number is two or more digits before hyphen(-) remove # only
eg
#162-7878 should be 162-7878, #12-4598866 should be 12-4598866)
if # and number is single digit before hyphen(-) remove # and add 0
eg
#1-7878 should be 01-7878
let arrstr=["#12-1676","#02-8989898","#676-98908098","12-232","02-898988","676-98098","2-898988"]
for(let st of arrstr)
console.log(st.replace(/#?(d)?(d-)/g ,replacer))
function replacer(match, p1, p2, offset, string){
let replaceSubString = p1 || "0";
replaceSubString += p2;
return replaceSubString;
}