设为首页 加入收藏

TOP

开发中日常操作转化工具类(八)
2014-11-24 12:02:24 来源: 作者: 【 】 浏览:227
Tags:开发 日常 操作 转化 工具
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))
{
首页 上一页 5 6 7 8 9 下一页 尾页 8/9/9
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇数学运算工具类 下一篇利用JDBC连接取数据并导入到EXCEL..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: