Counting the number of occurences of a substring within a string using the Split and UBound functions

If you are unfamiliar with the Split and UBound functions you may want to read our tutorial on array functions

<%
Dim myString, tempString, iHowManyTimes
myString ="This is a test"
tempString = Split(myString, "is")
iHowManyTimes = UBound(tempString)
Response.write "There are " & iHowManyTimes & " occurences."
%>

Output: There are 2 occurences.

Get the best asp web hosting provider now and save 30%

Advertisements



MembersPro

MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.