正则表达式 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);
        }
        */
        
        
    }

}
原文地址:https://www.cnblogs.com/lxh520/p/8467175.html