应用技巧

关注公众号 jb51net

关闭
首页 > 网络编程 > ASP编程 > 应用技巧 > asp计算字符串出现次数

ASP计算str2在str1中出现的次数

作者:

可以方便计算一个字符串在另一个字符串出现的次数
function CountStr(str1,str2)
       dim tmp,i,j
       if str1="" or isnull(str1) then
                 j=0
       elseif str2="" or isnull(str2) then
                 j=1
       else
                tmp=split(str1,str2)
                j=0
               for i=0 to ubound(tmp)
                          if tmp(i)<>"" then j=j+1
               next
        end if
        countstr=j
end function
阅读全文