码迷,mamicode.com
首页 > 编程语言 > 详细

Java正则表达式的用法

时间:2017-06-29 22:10:05      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:att   bool   str   返回   用法   stat   logs   表达   ram   

/**
* 校验时间格式,正确则返回true
* @param xxx
* @return
*/
private static boolean checkDateFormat (String xxx) {
String correctDateFormat = "^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\\s((([0-1][0-9])|(2?[0-3]))\\:([0-5]?[0-9])((\\s)|(\\:([0-5]?[0-9])))))?$";
boolean result = Pattern.matches(correctDateFormat, xxx);
return result;
}

 

Java正则表达式的用法

标签:att   bool   str   返回   用法   stat   logs   表达   ram   

原文地址:http://www.cnblogs.com/chenglc/p/7096198.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!