• 正则表达式 1


    package match;
    
    public class TestOne {
    
        public static void main(String[] args) {
    
            //2015-10-19 08:00:00.0
            /*if ("0800000".matches("[0-9]{4,}") == false) {
                System.out.println(true);
            }else {
                System.out.println(false);
            }*/
            
            
        /*    if ("abc.2".matches("[a-z]{1,}[.][0-9]")) {
                System.out.println(true);
            }else {
                System.out.println(false);
            }*/
            
            
            
    /*        /////                  +                 {m,n}:最少匹配m次,最多匹配n次
            if ("foo".matches("fo+")) {//匹配前面子表达式1次或多次 等价于 {1,}
                System.out.println(true);
            }else {
                System.out.println(false);
            }
            
            if ("foo".matches("fo{1,2}")) {
                System.out.println(true);
            }else {
                System.out.println(false);
            }
            
            
            /////                    ?                    {m,n}:最少匹配m次
            if ("does".matches("do(es)?")) {//匹配前面的子表达式0次或者1次,等价于 {0,1}
                System.out.println(true);
            }else {
                System.out.println(false);
            }
            
            if ("doeses".matches("do(es){0,2}")) {//匹配前面的子表达式0次或者1次,等价于 {0,1}
                System.out.println(true);
            }else {
                System.out.println(false);
            }
            
            /////////     *    匹配前面的字符任意次    等价于    {0,}
            
            */
            
            
    /*        if ("a".matches("[abc]")) { //匹配 [] 集合中的字符
                System.out.println(true);
            }else {
                System.out.println(false);
            }
            
            if ("a".matches("[^abc]")) { //匹配不在 [] 集合中的字符
                System.out.println(true);
            }else {
                System.out.println(false);
            }*/
            
            
    /*        ///////////////    | 
            if ("x".matches("x|y")) { //匹配x或者y
                System.out.println(true);
            }else {
                System.out.println(false);
            }
            
            if ("xoo".matches("[x|y]oo")) { //匹配x或者y
                System.out.println(true);
            }else {
                System.out.println(false);
            }
            */
            
            
        }
    
    }
  • 相关阅读:
    c# winform DataGridView导出数据到Excel中,可以导出当前页和全部数据
    水晶报表动态加载图片(签名)
    第1章 开启Threejs之旅(一)
    Python中@contextmanager的用法
    Systemd
    Python中with的用法
    systemctl的配置和使用
    /*CS5460_Note_1*/
    Just try the code
    MCP2515无BUG版本驱动(C文件)
  • 原文地址:https://www.cnblogs.com/lxh520/p/8467175.html
Copyright © 2020-2023  润新知