如何取得一个字符串在另外一个字符串中出现的次数

来源:互联网 发布:特效素材软件下载 编辑:程序博客网 时间:2024/05/12 23:26

如何取得一个字符串在另外一个字符串中出现的次数

问题:
怎样取得一个字符串在另外一个字符串中出现的次数?
方法:

程序代码

Function strCount(strA, strB)
lngA = Len(strA)
lngB = Len(strB)
lngC = Len(Replace(strA, strB, ""))
strCount = (lngA - lngC) / lngB
End Function

str="ddd,sdfdfgggdd"
d_count=ubound(split(str,"d",-1,1))
response.write "d的个数:" & cstr(d_count)

f_count=ubound(split(str,"f",-1,1))
response.write "f的个数:" & cstr(f_count)

g_count=ubound(split(str,"g",-1,1))
response.write "g的个数:" & cstr(g_count)

原创粉丝点击