/*计算子字符串在字符中出现的次数*/
//字符串
var str1 = 'zhulinjia zh lia tjqig qgx gja xx yy xxf xxxq wqja ix'
//子串
var str2 = 'a'
alert( Tongji(str1 , str2) )
//统计
function Tongji(string , char)
{
var index = 0 , index1 = 0 , count = 0
for(var i = 0i <string.length &&( index1 !dao= -1 )i++ )
{
index1 = string.indexOf(char, index)
index = index1 + 1
count = i
}
return count
}
var str='1/2/3/2/4/2/3/1/3'var arr=new Array()
var ss=str.split('/')
for(var i=0i<ss.lengthi++){
if(arr[ss[i]]) arr[ss[i]]++
else arr[ss[i]]=1
}
for(var a in arr){
alert(a+':'+arr[a])
}