Empty(str))
{
result = true;
}
result = !Util.test("^[-~!@#$%^&*()_+|=\\;':\",./<> ]+$", str);
return result;
}
/**
*〈验证只能为汉字〉
* @param str 待验证字符串
* @param prop prop
* @return boolean
*/
protected static boolean chinese(String str)
{
if (Util.isEmpty(str))
{
return true;
}
return Util.test("^[\u4E00-\u9FA5]+$", str);
}
/**
*〈验证只能为字母〉
* @param str 待验证字符串
* @return boolean
*/
protected static boolean letter(String str)
{
if (Util.isEmpty(str))
{
return true;
}
return Util.test("^[a-zA-Z]+$", str);
}
/**
*〈验证数字是否在指定范围〉
* @param str str
* @param prop prop
* @return boolean
*/
protected static boolean number(String str)
{
return true;
}
/**
*〈验证手机号码〉
* @param str 待验证字符串
* @param prop prop
* @return boolean
*/
protected static boolean mobile(String str)
{
if (Util.isEmpty(str))
{
return true;
}
return Util.test("^1\\d{10}$", str);
}
/**
*〈验证IP〉
* @param str 待验证字符串
* @param prop prop
* @return boolean
*/
protected static boolean checkIP(String str)
{
if (Util.isEmpty(str))
{
return true;
}
String pattern = "^( :[01] \\d\\d |2[0-4]\\d|25[0-5])(\\.( :[01] \\d\\d |2[0-4]\\d|25[0-5])){3}$";
return Util.test(pattern, str);
}
/**
*〈验证日期〉
* @param str 待验证字符串
* @param prop prop
* @return boolean
*/
protected static boolean date(String str)
{
String pattern = "";
if (Util.isEmpty(str))
{
return true;
}
SimpleDateFormat format = new SimpleDateFormat(pattern);
try
{
format.parse(str);
}
catch (ParseException e)
{
return false;
}
return true;
}
/**
*〈验证邮编〉
* @param str 待验证字符串
* @param prop prop
* @return boolean
*/
protected static boolean postalCode(String str)
{
if (Util.isEmpty(str))
{
return true;
}
//暂未实现
return true;
}
/**
*〈验证EMAIL〉
* @param str 待验证字符串
* @param prop prop
* @return boolean
*/
protected static boolean email(String str)
{
if (Util.isEmpty(str))
{
return true;
}
return Util.test("^[a-zA-Z0-9_.]+@\\w+\\- \\w+(\\.\\w+)$", str);
}
/*
*〈验证身份证〉
* @param str 待验证字符串
* @param prop prop
* @return boolean
*/
/* public static boolean checkID(String str)
{
if (Util.isEmpty(str))
{
return true;
}
if (Util.test("^\\d{17}[xX\\d]$", str))
{