/**
为空返回true
* 判断给定字符串是否空白串。 空白串是指由空格、制表符、回车符、换行符组成的字符串 若输入字符串为null或空字符串,返回true
*
* @param input
* @return boolean
*/
public static boolean isEmpty(String input) {
if (input == null || "".equals(input))
return true;
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
return false;
}
}
return true;
}
// 判断手机号码是否规则,true表示符合
public static boolean isPhoneNumber(String input) {
String regex = "(1[0-9][0-9]|15[0-9]|18[0-9])\\d{8}";
Pattern p = Pattern.compile(regex);
return p.matches(regex, input);
}
android字符串为空为号码判断
最新推荐文章于 2023-06-09 14:02:10 发布