Pattern p2 = Pattern.compile("^((\\+{0,1}0{0,2}86){0,1})");
Matcher m2 = p2.matcher(phoneNum);
StringBuffer sb = new StringBuffer();
while (m2.find())
{
m2.appendReplacement(sb, "");
}
m2.appendTail(sb);
return sb.toString();
用正则表达式替换手机号码前缀86
最新推荐文章于 2024-12-03 09:07:29 发布
本文介绍了一种使用正则表达式去除电话号码中的特定前缀的方法。通过Pattern和Matcher类实现,该方法能有效移除电话号码开头的'+086'等前缀,适用于多种应用场景。
1058

被折叠的 条评论
为什么被折叠?



