<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] # 正則提取 <br> >[info]String.math(RegExp),在string字符串中查找跟正則表達式匹配的文本,**成功返回是個數組**,**不成功返回的是null??** <br> ### 1.提取數字 ```javascript var str="中國移動:10086,中國聯通:10010,中國電信:10000"; //在str中查找跟正則表達式匹配的文本,成功返回是個數組,不成功返回的是null // 加了修飾符g,自然是在全局范圍內查找滿足正則表達式的文本 var array = str.match(/\d+/g);//匹配成功返回值是數組 console.log(array); ``` ![](https://img.kancloud.cn/a0/ed/a0ed4da9515e7a97046ece82867f00d8_248x134.png) <br> ### 2.提取郵箱 ```javascript var str = "123123@xx.com,fangfang@valuedopinions.cn 286669312@qq.com 2、emailenglish@emailenglish.englishtown.com 286669312@qq.com..."; var array = str.match(/\w+@\w+\.\w+(\.\w+)?/g); console.log(array); ``` ![](https://img.kancloud.cn/91/24/9124c719beb0c6361d25879a74cb7b2a_464x201.png) <br> ### 3.分組提取 RegExp 是javascript中的一個內置對象。為正則表達式。 RegExp.$1是RegExp的一個屬性,指的是與正則表達式匹配的第一個 子匹配(以括號為標志)字符串 以此類推,下一個為RegExp.$2 RegExp.$3 RegExp.$... ***** #### 3.1提取日期 ```javascript //提取日期中的年部分 $1年 $2月 $3日 var str = '2020-11-12'; // 正則表達式中的()作為分組來使用,獲取分組匹配到的結果用Regex.$1 $2 $3....來獲取 var date = str.match(/(\d{4})[-](\d{2})[-](\d{2})/);//返回值是數組 console.log(date); console.log(RegExp.$1); //年 console.log(RegExp.$2);//月 console.log(RegExp.$3);//日 ``` ![](https://img.kancloud.cn/66/92/66929fefd944f3195af2aca8a5874285_310x298.png) #### 3.2提取郵箱 ```javascript var email = "xuege@163.com"; email.match(/(^[0-9a-zA-Z_.-]+)[@]([0-9a-zA-Z_.-]+)(([.]com|cn+){1,2}$)/); console.log(RegExp.$1);//用戶名 console.log(RegExp.$2);// 163 console.log(RegExp.$3);// .com ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看