我看不出這個正則表達式。我正在使用以下代碼來確定電話號碼是否正確需要這種電話號碼格式的正則表達式
public static boolean verifyPhoneNum(String phone) {
Pattern pattern = Pattern.compile("^[0-9*#+]+$");
Matcher matcher = pattern.matcher(phone.trim());
return matcher.matches();
}
但它不按預期方式工作。電話號碼可以有任意數量的數字,#, - ,+,空格,(和)
我使它儘可能地寬鬆。我只是基本上不想在那裏的信件(和最好的任何其他特殊字符)
任何幫助嗎?由於
你想要一個文字「*」還是試圖捕獲重複數字? –