十月 04, 2008 位於 星期六, 十月 04, 2008 張貼者: joehwang
做個筆記,省的每次都忘記XD //被搜尋的字串str1="abcgdefgggg"//關鍵字key="gg"document.write(CountKeyword(str1,key));function CountKeyword(str,keyword){ index = 0; count = 0; while (index!=-1){ index = str.indexOf(keyword,index); if (index!=-1){ index = index + keyword.length; count++; } } return count;}