久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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)站

      javascript怎么樣判斷字符串中是否包含某個字符串

      javascript判斷字符串中是否包含某個字符串的方法:1、使用【indexOf()】方法;2、使用【search()】方法;3、使用【match()】方法。

      javascript怎么樣判斷字符串中是否包含某個字符串

      本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版,DELL G3電腦。

      javascript判斷字符串中是否包含某個字符串的方法:

      方法一: indexOf()

      var str = "123"; console.log(str.indexOf("3") != -1 );  // true

      indexOf() 方法可返回某個指定的字符串值在字符串中首次出現(xiàn)的位置。如果要檢索的字符串值沒有出現(xiàn),則該方法返回 -1。

      方法二: search()

      var str = "123"; console.log(str.search("3") != -1 );  // true

      search() 方法用于檢索字符串中指定的子字符串,或檢索與正則表達式相匹配的子字符串。如果沒有找到任何匹配的子串,則返回 -1。

      方法三:match()

      var str = "123"; var reg = RegExp(/3/); if(str.match(reg)){     // 包含         }

      match() 方法可在字符串內(nèi)檢索指定的值,或找到一個或多個正則表達式的匹配。

      相關免費學習推薦:javascript視頻教程

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