【发布时间】:2017-09-08 11:19:56
【问题描述】:
我已经使用正则表达式完成了格式化:
<p class="phone">2124771000</p>
$(".phone").text(function(i, text) {
text = text.replace(/(\d\d\d)(\d\d\d)(\d\d\d\d)/, "$1-$2-$3");
return text;
});
使用上面的这个例子,我可以转换 212-477-1000:
<p class="phone">ABC1234</p>
现在我想用上面的文字制作 ABC-1234 字符串。
【问题讨论】:
标签: javascript php regex