zoukankan      html  css  js  c++  java
  • 几个可以用到的正则表达式

    package lbi.flow.util;
    
    import net.sf.json.regexp.RegexpMatcher;
    
    public class RegexpUtils {
        /**
         * 匹配7c:d1:c3:73:d6:72形式mac
         * 
         * @return
         */
        public static RegexpMatcher getMacMatcher() {
            return net.sf.json.regexp.RegexpUtils
                    .getMatcher("[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]");
        }
    
        /**
         * 匹配20140430235959形式日期
         * 
         * @return
         */
        public static RegexpMatcher getTimeMatcher() {
            return net.sf.json.regexp.RegexpUtils
                    .getMatcher("^(?:(?!0000)[0-9]{4}(?:(?:0[1-9]|1[0-2])(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)([01][0-9]|2[0-3])[0-5][0-9][0-5][0-9]$");
        }
    
        /**
         * 匹配2014-04-30 23:59:59形式日期
         * 
         * @return
         */
        public static RegexpMatcher getTimeMatcher2() {
            return net.sf.json.regexp.RegexpUtils
                    .getMatcher("^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)\s+([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$");
        }
    
        /**
         * 匹配20140430形式日期
         * 
         * @return
         */
        public static RegexpMatcher getDateMatcher() {
            return net.sf.json.regexp.RegexpUtils
                    .getMatcher("^(?:(?!0000)[0-9]{4}(?:(?:0[1-9]|1[0-2])(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$");
        }
    
        /**
         * 匹配2014-04-30形式日期
         * 
         * @return
         */
        public static RegexpMatcher getDateMatcher2() {
            return net.sf.json.regexp.RegexpUtils
                    .getMatcher("^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$");
        }
    }

    工作时候正好用到了,顺便记录下来,以备后用。

    参考地址:http://blog.csdn.net/lxcnn/article/details/4362500

        http://www.cnblogs.com/deerchao/archive/2006/08/24/zhengzhe30fengzhongjiaocheng.html

  • 相关阅读:
    15个常用的Excel函数公式
    Excel常用公式大全
    Python+Selenium-select
    Python+Selenium--操作测试对象
    Python+Selenium--鼠标事件
    Python+Selenium--键盘事件
    Python+Selenium--设置等待时间
    Python+Selenium--定位iframe中的对象
    Python+Selenium--启动及关闭浏览器
    Tomcat安装详解
  • 原文地址:https://www.cnblogs.com/lcxdever/p/3738759.html
Copyright © 2011-2022 走看看