Function CheckTheChar(TheChar,TheString)
'TheChar="The string to be detected"
'TheString="String to be detected"
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="this character"&CheckTheChar&"times"
else
CheckTheChar="0 times"
end if
End Function
example:
program code
Response.Write CheckTheChar("everyone","a224everyone4a434a4everyone654arewr4a4a")
program code
<%
'Detect the number of times string Str1 appears in string Str2
Public Function SearchChar(Str1, Str2)
Dim I, Counter
Counter = 0
If InStr(Str2, Str1) Then
For I = 1 To Len(Str2)
If Mid(Str2, I, Len(Str1))=Str1 Then
Counter = Counter + 1
End If
Next
End if
SearchChar=Counter
End Function
%>
<form name="form1" method="post" action="">
<p>Enter two strings:</p>
<p> String 1:
<input name="text1" type="text" id="text">
</p>
<p> String 2:
<input name="text2" type="text" id="text">
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<%
Dim
X=Request.Form("text1")
Y=Request.Form("text2")
If X<>"" and Y<>"" Then
%>
<p>String 1: <%=X%></p>
<p>String 2: <%=Y%></p>
<p>The number of times string 1 appears in string 2<%=SearchChar(X,Y)%></p>
<%
End If
%>
After a simple transformation, it can be turned into a function that detects when there are more than 2 URLs in the message content and blocks it.