In VbScript (ASP usage), can anyone tell me how i would check to see how many times a string occurs in another string?
Thanks for your time, patience, and money.
Printable View
In VbScript (ASP usage), can anyone tell me how i would check to see how many times a string occurs in another string?
Thanks for your time, patience, and money.
Code:<%@ Language=VBScript %>
<%option explicit%>
<HTML>
<BODY>
<%
dim strTemp
strTemp = "big bad pig big hod bad door fig"
response.write strTemp & "<BR>"
response.write oc(strTemp,"bad")
Function oc(strIn, strTest)
Dim i
Dim j
Dim l
l = Len(strTest)
i = InStr(strIn, strTest)
While i > 0
j = j + 1
strIn = Mid(strIn, i + l)
i = InStr(strIn, strTest)
Wend
oc = j
End Function
%>
</BODY>
</HTML>
Changing Marks code..
to a simpler way...
<%@ Language=VBScript %>
<%option explicit%>
<HTML>
<BODY>
<%
dim strTemp,myArray
strTemp = "big bad pig big hod bad door fig"
response.write strTemp & "<BR>"
myArray = Split(strTemp,"bad",-1,1)
response.write Ubound(myArray)
%>
</BODY>
</HTML>
That's neat Active!
you guys rule. thanks a lot!