memberlogin
contactus
randomfacts

Find substring in a string with vbscript

Finding a substring in a string is simple.  Using the InStr(string,substring) function will return the index of the first character of the substring if it is found in the string, or 0 if the substring is not found.

<%

       mylist = "red,green,brown,yellow"

       searchword = "brown"

        if inStr(mylist,searchword) > 0 then

               Response.write "found the substring"

        else

              Response.write "couldn\'t find the substring"

        end if

%>