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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] # 1.string中支持正則的api ## 1.match()將所有匹配的字符(內容)提取出來,返回數組 //語法 ``` stringObject.match(searchvalue) stringObject.match(regexp) ``` 例子 ``` var str = "hello"; console.log(str.match(/l/g));// ["l", "l"] //g表示全局搜索 ``` ## 2.replace() 替換匹配的對象 ``` //語法 stringObject.replace(regexp/substr,replacement) var a = "hello"; var reg = /l/g; console.log(a.replace(reg,"*")); //"he**o" ``` ## 3.search() 方法用于檢索字符串中指定的子字符串的位置 ``` //語法 stringObject.search(regexp)/ //注釋:如果沒有找到任何匹配的子串,則返回 -1。 var a = "hello world"; var reg = /l/; console.log(a.search(reg)); //2 加g也是2只能匹配到第一個值 ``` ## 4.split(reg) 將字符串分割成數組 ``` var a = "hello"; var reg = /l/; console.log(a.split(reg)); //["he","",o"] //一個`l`分割一次 ``` # 2.正則自帶的api ## 1. test() //不加g > 測試字符串中是否存在匹配正則表示式的字符串,是有沒有的問題,為局部匹配而生的。返回boolean值 ``` var a ="aah"; var reg = /a/g; console.log(reg.test(a)); //true console.log(reg.test(a)); //true console.log(reg.test(a)); //false console.log(reg.test(a)); //true console.log(reg.test(a)); //true console.log(reg.test(a)); //false ``` //不加g 一直都時true //用test,最好不要加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>

                              哎呀哎呀视频在线观看