久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      JS 正則表達(dá)式的相關(guān)方法(正則學(xué)習(xí)筆記1)

      復(fù)制代碼 代碼如下:
      var str=”abcdefghijklnabcdefghijklmnabcabdefghijklmn”;
      re=/a/g;

      alert(re.test(str));
      //test方法調(diào)用返回 true false 表示是否在指定字符串找到匹配的字符–true

      alert(re.exec(str));
      //返回字符串中匹配表達(dá)式的第一個字符串 –a

      alert(str.match(re));
      //返回一個數(shù)組,每一項都匹配表達(dá)式的數(shù)組—[a,a,a] 注意正則一定要使用g全局變量

      alert(str.search(re))
      //返回匹配的正則第一次出現(xiàn)的位置從0開始,沒有找到返回-1 –0 *有點(diǎn)像indexOf*

      alert(str.replace(re,”b”))
      //替換*這個很簡單了。不用多說*

      alert(str.split(re)[0])
      //split一般用于把字符串分成數(shù)組 返回的是數(shù)組對象,這里返回了數(shù)組的0下標(biāo)的值

      用正則其實可以簡化很多操作。特別在對表單數(shù)據(jù)驗證上。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號