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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 一、創建正則表達式 ### 模式修飾符 * i 忽略大小寫 * g 全局,只要能匹配到的地方,都匹配 * m 多行匹配 ~~~ //第一種方式 var box=new RegExp('abcd','gi'); //第二種方式 var box=/abcd/gi; ~~~ ### 測試正則表達式的2種方法: #### test()方法 ,字符串中是否包含pattern,返回真假 ~~~ var pattern=/box/gi; var str="box is a box"; alert(pattern.test(str)); ~~~ #### exec();方法返回匹配數組,沒有返回null ~~~ var pattern=/box/g; var str="box is a box"; alert(pattern.exec(str)); ~~~ ### string提供的4種方法,可以用在正則表達式 * match(pattern); //返回匹配的數組或null * replace(pattern,new); //參數:替換前后的內容,返回新的字符串 * search(pattern); 返回pattern開始的位置,查到即返回,無需全局 * split(pattern); //返回拆分后的數組 ## 二、獲取控制 ![](https://box.kancloud.cn/a6b40550a35f52949d8c052436c164ea_703x277.png) ![](https://box.kancloud.cn/832fe1ecbf1a53cc832b34bf4f764e18_713x653.png) ![](https://box.kancloud.cn/391cdfd250098738b829b49c7a6ea9b6_687x485.png) ![](https://box.kancloud.cn/36d6a2aeff7b1591fef71a791e0aebde_681x96.png) ![](https://box.kancloud.cn/83238949390791339a7eeb418d225e86_686x234.png) ~~~ //一個點匹配一個字符 var pattern=/g..gle/gi; str = this is a google page! str.match(pattern); ~~~ 說明1: ~~~ /^0-9a-z/ //非0-9,非a-z /^[0-9]/ //行首0-9 ~~~ 說明2: ~~~ pattern.test(str); //不管何種方式。必須先運行一次 RegExp.$1; //獲取pattern中的第一個分組的內容 ~~~ ~~~ var pattern=/8(.*)8/; var str="this is a 8google8"; document.write(str.replace(pattern,'<strong>$1</strong>')); ~~~ 交換2個分組的位置 ~~~ var pattern=/(.*)\s(.*)/; var str="baidu google"; document.write(str.replace(pattern,'<strong>$2 $1</strong>')); ~~~
                  <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>

                              哎呀哎呀视频在线观看