|
-
Mar 11th, 2001, 05:46 PM
#1
Thread Starter
Hyperactive Member
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.
-
Mar 12th, 2001, 06:27 AM
#2
Frenzied Member
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>
-
Mar 12th, 2001, 06:39 AM
#3
Addicted Member
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>
-
Mar 12th, 2001, 06:54 AM
#4
Frenzied Member
-
Mar 12th, 2001, 08:48 PM
#5
Thread Starter
Hyperactive Member
you guys rule. thanks a lot!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|