• 正则测试


    <!DOCTYPE html>
    <html lang="en">
    
    <head>
      <meta charset="UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Document</title>
      <script src="./js/prism.js"></script>
      <link rel="stylesheet" href="./css/prism.css">
      <style>
        .content {
          display: flex;
        }
    
        .div {
          border: solid 1px red;
          flex: 1 1 0
        }
      </style>
      <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
      <script>
        function cli() {
          let _arguments = arguments
          for (let i = 0; i < _arguments.length; i++) {
            console.log(`我是第${i+1}个参数,值为${_arguments[i]}`);
          }
    
          var name = 'toastcashiern_K2mini_V2.3.1_general_20220216_RC.01.deb';
          let reg = /^.+_.+_.+_.+_.+_.+\.[0-9]+\..+/g;
          console.log(reg.test(name));
        }
    
        //计算版本号大小,转化大小
        function toNum(a) {
          var a = a.toString();
          var c = a.split('.');
          var num_place = ["", "0", "00", "000", "0000"],
            r = num_place.reverse();
          for (var i = 0; i < c.length; i++) {
            var len = c[i].length;
            c[i] = r[len] + c[i];
          }
          var res = c.join('');
          return res;
        }
        //检测插件版本号是否需要更新
        function checkPlugin(a, b) {
          let old_a = a;
          let old_b = b;
          var a = toNum(a);
          var b = toNum(b);
          if (a == b) {
            console.log("版本号相同!版本号为:" + old_a);
          } else if (a > b) {
            console.log("版本号" + old_a + "(" + a + ")" + "是新版本!");
          } else {
            console.log("版本号" + old_b + "(" + b + ")" + "是新版本!");
          }
        }
        var version = "1.0.4.235";
        var ocxWebVersion = "1.0.3.567";
        checkPlugin(version, ocxWebVersion);
    
        function swapArr(arr, index1, index2) {
          arr[index1] = arr.splice(index2, 1, arr[index1])[0];
          return arr;
        }
        let arr = [1, 2, 3, 4, 5]
        let arr2 = swapArr(arr, 0, 4)
        console.log(arr2);
    
        function cli2() {
          // let _html = document.getElementsByClassName('a')[0].innerHTML;
          // let _h2 = $(".a").html()
          let _txt = $('#txtTest').val();
          let reg = /^[0-9|a-z|A-Z]+\.[0-9|a-z|A-Z]+$/g
          if (reg.test(_txt)) {
            console.log(_txt);
            $("#txtResult").val(`匹配成功了:${_txt}`);
          } else {
            console.log('未匹配成功');
            $("#txtResult").val('未匹配成功');
          }
        }
      </script>
    </head>
    
    <body>
      <input type="text" name="" id="txtTest">
      结果: <input type="text" name="" id="txtResult">
      <button onclick="cli2()">获取</button>
    
      <br /><br /><br /><br /><br /><br /><br /><br /><br />
      <h1>下面忽略掉,其他的测试。。。。。。。。。</h1>
      <a class="a b">test</a>
    
      <button onclick="cli(1,2,3,4)">点击</button>
      <div class="content">
        <div class="div">我是一个div</div>
        <div class="div">我是一个很多字的div</div>
        <div class="div">我是一个很多字很多字的div</div>
        <div>
          <pre class="line-numbers"><code class="language-javascript">function add(a, b){
    	return a + b;
    }</code>
    </pre>
        </div>
    
      </div>
    </body>
    
    </html>
    

      

    <!DOCTYPEhtml>
    <htmllang="en">

    <head>
      <metacharset="UTF-8">
      <metahttp-equiv="X-UA-Compatible"content="IE=edge">
      <metaname="viewport"content="width=device-width, initial-scale=1.0">
      <title>Document</title>
      <scriptsrc="./js/prism.js"></script>
      <linkrel="stylesheet"href="./css/prism.css">
      <style>
        .content {
          display:flex;
        }

        .div {
          border:solid1pxred;
          flex:110
        }
      </style>
      <scriptsrc="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
      <script>
        functioncli() {
          let_arguments = arguments
          for (leti = 0; i<_arguments.length; i++) {
            console.log(`我是第${i+1}个参数,值为${_arguments[i]}`);
          }

          varname = 'toastcashiern_K2mini_V2.3.1_general_20220216_RC.01.deb';
          letreg =/^.+_.+_.+_.+_.+_.+\.[0-9]+\..+/g;
          console.log(reg.test(name));
        }

        //计算版本号大小,转化大小
        functiontoNum(a) {
          vara = a.toString();
          varc = a.split('.');
          varnum_place = ["", "0", "00", "000", "0000"],
            r = num_place.reverse();
          for (vari = 0; i<c.length; i++) {
            varlen = c[i].length;
            c[i] = r[len] +c[i];
          }
          varres = c.join('');
          returnres;
        }
        //检测插件版本号是否需要更新
        functioncheckPlugin(a, b) {
          letold_a = a;
          letold_b = b;
          vara = toNum(a);
          varb = toNum(b);
          if (a==b) {
            console.log("版本号相同!版本号为:"+old_a);
          } elseif (a>b) {
            console.log("版本号"+old_a+"("+a+")"+"是新版本!");
          } else {
            console.log("版本号"+old_b+"("+b+")"+"是新版本!");
          }
        }
        varversion = "1.0.4.235";
        varocxWebVersion = "1.0.3.567";
        checkPlugin(version, ocxWebVersion);

        functionswapArr(arr, index1, index2) {
          arr[index1] = arr.splice(index2, 1, arr[index1])[0];
          returnarr;
        }
        letarr = [1, 2, 3, 4, 5]
        letarr2 = swapArr(arr, 0, 4)
        console.log(arr2);

        functioncli2() {
          // let _html = document.getElementsByClassName('a')[0].innerHTML;
          // let _h2 = $(".a").html()
          let_txt = $('#txtTest').val();
          letreg =/^[0-9|a-z|A-Z]+\.[0-9|a-z|A-Z]+$/g
          if (reg.test(_txt)) {
            console.log(_txt);
            $("#txtResult").val(`匹配成功了:${_txt}`);
          } else {
            console.log('未匹配成功');
            $("#txtResult").val('未匹配成功');
          }
        }
      </script>
    </head>

    <body>
      <inputtype="text"name=""id="txtTest">
      结果: <inputtype="text"name=""id="txtResult">
      <buttononclick="cli2()">获取</button>

      <br/><br/><br/><br/><br/><br/><br/><br/><br/>
      <h1>下面忽略掉,其他的测试。。。。。。。。。</h1>
      <aclass="a b">test</a>

      <buttononclick="cli(1,2,3,4)">点击</button>
      <divclass="content">
        <divclass="div">我是一个div</div>
        <divclass="div">我是一个很多字的div</div>
        <divclass="div">我是一个很多字很多字的div</div>
        <div>
          <preclass="line-numbers"><codeclass="language-javascript">function add(a, b){
      return a + b;
    }</code>
    </pre>
        </div>

      </div>
    </body>

    </html>
  • 相关阅读:
    Logstash-input-jdbc同步mysql数据到ES - sql_last_value
    filebeat7.5.2 在 windows server 2008 R2 设置系统服务报错
    mysql8.0.19压缩版安装
    不是RESTful不好,是你姿势有问题
    logback运行时动态创建日志文件
    jpa 主键重复导致查询list的数据总是重复第一条数据
    解决MySQL Workbench导出低版本MySQL时报错Unknown table ‘column_statistics’ in information_schema的问题
    windows10系统修改JDK版本后配置环境变量不生效怎么办
    application.properties 中文乱码问题解决
    JAVA抽象类和抽象方法(abstract)
  • 原文地址:https://www.cnblogs.com/guozhe/p/16093440.html
Copyright © 2020-2023  润新知