/*************************************************************名稱:strcountinstring功能:計算一個字元在一個字串中出現的次數引數:sourcestr,源字串;findstr,需要查詢的字串;返回:findcount,統計次數*************************************************************/function strcountinstring(sourcestr,findstr) {sourcestr=new String(sourcestr);findstr=new String(findstr);var findcount=0;var startposition=0;while (startposition<sourcestr.length) {searchstr=sourcestr.indexOf(findstr,startposition);if (searchstr!=-1) {findcount=findcount+1;startposition=searchstr+findstr.length;} else {break;}}return(findcount);}
/*************************************************************名稱:strcountinstring功能:計算一個字元在一個字串中出現的次數引數:sourcestr,源字串;findstr,需要查詢的字串;返回:findcount,統計次數*************************************************************/function strcountinstring(sourcestr,findstr) {sourcestr=new String(sourcestr);findstr=new String(findstr);var findcount=0;var startposition=0;while (startposition<sourcestr.length) {searchstr=sourcestr.indexOf(findstr,startposition);if (searchstr!=-1) {findcount=findcount+1;startposition=searchstr+findstr.length;} else {break;}}return(findcount);}