PhoneUtils
生活随笔
收集整理的這篇文章主要介紹了
PhoneUtils
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
import java.util.regex.Matcher;
import java.util.regex.Pattern;public class PhoneUtils {/*** @param phoneNo* 加星號過的電話號碼*/public static String dealPhoneNo(String phoneNo) {return phoneNo.substring(0, 3) + "****" + phoneNo.substring(7);}/*** 通過正則表達式判斷是否為手機號* @param phoneString* @return*/public static boolean isPhoneNumber(String phoneString) {String format = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";return isMatch(format, phoneString);}/*** 字符串正則校驗* @param regex* 正則表達式* @param string* 需要檢驗的字符串* @return*/public static boolean isMatch(String regex, String string) {Pattern pattern = Pattern.compile(regex);Matcher matcher = pattern.matcher(string);return matcher.matches();}
}
?
轉載于:https://www.cnblogs.com/loaderman/p/6435098.html
總結
以上是生活随笔為你收集整理的PhoneUtils的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 正点原子STM32F103学习笔记(一)
- 下一篇: NAND FLASH分区规划