Commit aaaf3cc2 by zhengxj

finish 手机号判断 on 20190124 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17062 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 12ffc3a0
......@@ -12,6 +12,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 字符串工具类
......@@ -66,7 +68,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * @return true:为空 false:非空
*/
public static boolean isEmpty(Object[] objects) {
return isNull(objects) || (objects.length == 0);
return isNull(objects) || objects.length == 0;
}
/**
......@@ -153,7 +155,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* 去空格
*/
public static String trim(String str) {
return (str == null ? "" : str.trim());
return str == null ? "" : str.trim();
}
/**
......@@ -234,11 +236,11 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
boolean nextUpperCase = true;
if (i < (s.length() - 1)) {
if (i < s.length() - 1) {
nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
}
if ((i > 0) && Character.isUpperCase(c)) {
if (i > 0 && Character.isUpperCase(c)) {
if (!upperCase || !nextUpperCase) {
sb.append(SEPARATOR);
}
......@@ -320,7 +322,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
double dblR = Math.random() * len;
int intR = (int) Math.floor(dblR);
char c = strTable.charAt(intR);
if (('0' <= c) && (c <= '9')) {
if ('0' <= c && c <= '9') {
count++;
}
retStr += strTable.charAt(intR);
......@@ -497,4 +499,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
return set.toArray(result);
}
public static boolean isMobile(String str) {
Pattern p = null;
Matcher m = null;
boolean b = false;
String s2="^[1](([3][0-9])|([4][5,7,9])|([5][4,6,9])|([6][6])|([7][3,5,6,7,8])|([8][0-9])|([9][8,9]))[0-9]{8}$";// 验证手机号
if(StringUtils.isNotBlank(str)){
p = Pattern.compile(s2);
m = p.matcher(str);
b = m.matches();
}
return b;
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!