首页 > 编程语言 > 详细

java正则表达式

时间:2020-03-22 17:59:53      阅读:57      评论:0      收藏:0      [点我收藏+]

这是一个检测时间格式是否正确的方法,例如2020-03-22

 1 public static boolean isValidateRunningDate(String input) {
 2         //正则匹配
 3         Matcher matcher = null;
 4         boolean result = false;
 5         String regex = "[0-9]{4}-[0-9]{2}-[0-9]{2}";
 6         if (input != null && !input.isEmpty()) {
 7             Pattern pattern = Pattern.compile(regex);
 8             matcher = pattern.matcher(input);
 9         }
10         if (matcher != null) {
11             result = matcher.matches();
12         }
13         return result;
14     }

 

java正则表达式

原文:https://www.cnblogs.com/fxw-learning/p/12546803.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!