<%
Function GetSubstringCount(strToSearch, strToLookFor, bolCaseSensative)
If bolCaseSensative then
GetSubstringCount = UBound(split(strToSearch, strToLookFor))
Else
GetSubstringCount = UBound(split(UCase(strToSearch), UCase(strToLookFor)))
End If
End Function
Dim str, strToLookFor
str = Request("txtString")
strToLookFor = Request("txtToLookFor")
Dim iCount
iCount = GetSubstringCount(str, strToLookFor, False)
If Len(str) > 0 then
%>
<b>There were <%=iCount%> occurrences of
"<%=strToLookFor%>" in "<%=str%>"</b>
<p><hr><p>
<% End If %>
<form method=post>
Enter a string:<br>
<textarea name="txtString" wrap="virtual" cols="40" rows="5"><%=str%></textarea>
<p>
Enter a string to search for in the above string:<br>
<input name="txtToLookFor" type="text" value="<%=strToLookFor%>">
<p><input type="submit" value="Submit">
</form>
|