ASP搜索问题!

来源:百度知道 编辑:UC知道 时间:2024/05/15 18:10:20
问题:如何在一段字符内搜索指定字符是否存在以及重复出现几次!

例如:
txt="a1a2a3"
如何判断txt里是否含有“a”,并且这个“a”在txt里出现了几次!
实际使用的时候可能是从几千字里去搜索!

Function CheckTheChar(TheChar,TheString)
'TheChar="要检测的字符串"
'TheString="待检测的字符串"
if inStr(TheString,TheChar) then
for n =1 to Len(TheString)
if Mid(TheString,n,Len(TheChar))=TheChar then
CheckTheChar=CheckTheChar+1
End if
Next
CheckTheChar="这个字符"&CheckTheChar&"次"
else
CheckTheChar="0次"
end if
End Function