<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ~~~ /* * 正則捕獲:把一個字符串中和正則匹配的部分獲取到 * [正則] * exec * test * * [字符串] * replace * split * match * ... */ /* * 基于EXEC可以實現正則的捕獲 * 1.如果當前正則和字符串不匹配,捕獲的結果是NULL * 2.如果匹配,捕獲的結果是一個數組 * 0:大正則捕獲的內容 * index:正則捕獲的起始索引 * input:原始操作的字符串 * ... * 3.執行一次EXEC只能捕獲到第一個和正則匹配的內容,其余匹配的內容還沒有捕獲到, * 而且更惡心的是,我傻傻的執行多次,然而并沒啥卵用 =>“正則的捕獲有懶惰性”: * 只能捕獲到第一個匹配的內容,剩余的默認捕獲不到 */ // let str = 'zhufeng2018peixun2019'; // let reg = /\d+/; // console.log(reg.exec('zhufengpeixun'));//=>null // console.log(reg.exec(str));//=>['2018',index:7,input:...] //=>LAST-INDEX不變導致了正則捕獲的懶惰性 // console.log(reg.lastIndex);//=>0 正則捕獲時候,下一次在字符串中開始查找的索引 // console.log(reg.exec(str));//=>['2018'] // console.log(reg.lastIndex);//=>0 // console.log(reg.exec(str));//=>['2018'] //=>即使我們手動修改了LAST-INDEX,然而還是沒啥卵用 // console.log(reg.exec(str));//=>['2018'] // reg.lastIndex = 11; // console.log(reg.lastIndex); // console.log(reg.exec(str));//=>['2018'] //=>解決正則捕獲的懶惰性,我們需要加全局修飾符G(這個是唯一的方案, // 而且不加G不管用什么辦法捕獲,也都不能把全部匹配的捕獲到) // let str = 'zhufeng2018peixun2019'; // let reg = /\d+/g; // console.log(reg.lastIndex);//=>0 // console.log(reg.exec(str));//=>['2018'] // console.log(reg.lastIndex);//=>11 // console.log(reg.exec(str));//=>['2019'] // console.log(reg.lastIndex);//=>21 // console.log(reg.exec(str));//=>null // console.log(reg.lastIndex);//=>0 // console.log(reg.exec(str));//=>['2018'] // //... // let str = 'zhufeng2018peixun2019yangfan2020qihang2021'; // let reg = /\d+/g; /*RegExp.prototype.myExecAll = function (str) { //=>this:reg 當前操作的正則 //=>str:我們要捕獲的字符串 //=>執行EXEC開始捕獲,具體捕獲多少次不定,但是一直到捕獲不到內容(NULL)為止, 期間把捕獲到的內容存儲到數組中即可 //=>為了防止出現死循環:我們檢測一下正則是否加G,沒有加G只把第一次捕獲的結果返回即可 if (!this.global) { return this.exec(str); } let result = [], valAry = this.exec(str); while (valAry) {//=>this.lastIndex < str.length result.push(valAry[0]);//=>把每一次正則捕獲到的結果第一項(具體捕獲的內容)存儲到容器中 valAry = this.exec(str); } return result; };*/ // console.log(reg.myExecAll(str)); // console.log(str.match(reg));//=>MATCH實現了我們自己編寫的EXEC-ALL處理的事情, // 正則不加G返回第一個匹配的即可,加了G,把所有匹配的內容都捕獲到,最后統一存儲到一個數組中返回 ~~~
                  <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>

                              哎呀哎呀视频在线观看