我有这样一种情况,需要从字符串中删除任何前导零,例如
02-03
,02&03
,02
,03
。我有这个正则表达式(s.replace(/^0+/, '');
)来删除前导零,但我需要能够处理上述情况的内容。
let strings = [`02-03`, `02&03`, `02`,`03`]
strings.forEach(s => {
s = s.replace(/^0+/, '');
console.log(s)
})