zoukankan      html  css  js  c++  java
  • 正则表达式 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);
            }
            */
            
            
        }
    
    }
  • 相关阅读:
    纯css改变下拉列表select框的默认样式
    jquery 购物车
    如何统计页面标签使用次数?
    uni-app—从安装到卸载
    详解Vue 方法与事件处理器
    LoadRunner
    Python-函数
    Python-函数
    python-列表
    python-循环
  • 原文地址:https://www.cnblogs.com/lxh520/p/8467175.html
Copyright © 2011-2022 走看看