謝晒的PHP網頁設計
聯絡E-mail:
sean0704@gmail.com
站內搜尋
Tuesday, June 26, 2012
[JavaScript] 簡單的字串搜尋
var str = "Hi Av8d";
var chk = str.search(/hi/i);
if(
chk==-1){
alert("hi不在
Hi Av8d
字串中");
}else{
alert("hi有在
Hi Av8d
字串中"); //本案例會跳出這個視窗
}
備註:後面加參數i,代表不區分大小寫。
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment