Find text in a string, compare two strings for similar match VBScript ASP classic

According to the Microsoft Docs, The InStr(string1, string2)  function returns the position of the first occurrence of one string within another.

We can use this to find a string within another one. For example. I wish to see if an email address is from the Skagit.edu domain. I want to see if the address is firstname.lastname@skagit.edu so I can use the first and last name in a greeting.

string1=”@skagit.edu”
string2=”firstname.lastname@skagit.edu”

stringcount = InStr(string1, string2)

If stringcount>0 Then
response.write(“We have a skagit.edu domain address”)
Else
response.write(“This is not a skagit.edu email address”)
End If

Leave a Reply