• js 正则 测试


            var str0 = '2013-6-7()';
            var AAAAADD = str0.match(/(d)/g); //11个空字符串  //["2", "0", "1", "3", "6", "7"]
            var AAAAAD = str0.match(/d/g); //11个空字符串      // ["2", "0", "1", "3", "6", "7"]
            var AAAAAD1 = str0.match(/d+/g);                   //["2013", "6", "7"]
            var AAAAAD2 = str0.match(/(d+)/g);                 //["2013", "6", "7"]
            var AAAAAD3 = str0.match(/d+-/g);              //["2013-", "6-"]
            var AAAAAD4 = str0.match(/d+(-)/g);              //["2013-", "6-"]
            var AAAAAD5 = str0.match(/(d+)(-)/g);              //["2013-", "6-"]

            ///   (d+)(-)/g = /d+(-)/g = /d+-/g        ||  /d+/g = /(d+)/g  || /d/g = /(d)/g
            var data = 'windows 98 is ok';
            console.log(data);
            console.log(data.match(/windows (?=d+)/));  // ["windows "]   //(?=)会作为匹配校验,但不会出现在匹配结果字符串里面
            console.log(data.match(/windows (?:d+)/));  // ["windows 98"]   //(?:)会作为匹配校验,并出现在匹配结果字符里面
            console.log(data.match(/windows (d+)/));    // ["windows 98", "98"] //先匹配windows 98,在匹配98
            var str = "dskf(AAA)_8hjk(CCC)dsk(BBB)";
            var reg = /(?:()w+(?:))/;
            var reg = /(?:()(?:))/;
            console.log(str.match(/(?:()/));//(
            console.log(str.match(/w+/)); //dskf
            console.log(str.match(/(?:))/));//)
            console.log("10000");
            console.log(str.match(/(?:()(?:))/)); //匹配(),
            console.log(str.match(/(?:()w+(?:))/)); //["(AAA)"]
            console.log(str.match(/(?:()(w+)(?:))/)); //["(AAA)".AAA]
      data = "blang001";
            console.log(data);
            console.log(data.match(/blang/i)); //["blang"]
            console.log(data.match(/D/ig)); //["b"]  吧不是数字的提取出来  ["b", "l", "a", "n", "g"]
            console.log(data.match(/lang/i)); // lang 代表非blang 字符串, 
            console.log(data.match(/lang(?:0)/));
    
            var lang = /lang(?:uage)?-([w-]+)/i;
            var sss = "line-numbers language-javascript";
            var ss1 = "language-css";
            var ss2 = "'+lan_class+'";
            var lang = /lang(?:uage)?-([w-]+)/i;   //var re = /one/;  // e后面必须是独立的 可以是起始,空格,或结束 w : 字符 ( 字母 ,数字,下划线_ )
            console.log(sss); //?-等同于-,判断后面是否是-,  ?(-)等同于(-)
            console.log(sss.match(lang)); //["language-javascript", "javascript"]
            console.log(ss1.match(lang)); //["language-css", "css"]
            console.log(ss2.match(lang));
  • 相关阅读:
    自制一个超级简单的 php 发邮件的轮子 simpleMailTool.php
    未来会变成什么样子呢
    【Example】C++ 标准库 std::atomic 及 std::memory_order
    ABP Framework 5.3.0 版本新增功能和变更说明
    一个算子在 MindSpore 框架中的执行流程
    努力自律
    智商税
    逼着自己自律
    分享一个不错的hooks库
    Sandbox 沙箱
  • 原文地址:https://www.cnblogs.com/enych/p/9197876.html
Copyright © 2020-2023  润新知