Check array items "this is item one" contained in a string (page source)

Johnson

Well-known member
Joined
Mar 6, 2009
Messages
158
Programming Experience
Beginner
Hi. basically i have Three messages in an array

VB.NET:
    Private MyArry() As String = {"This is Message one", "This is Message Two", "This is Message Three"}

I want to compare it agasint a string which is a web sites page source.

If it contains one of three messages return true.
bit stuck
 
Can't you just do (assuming you have the web page source "strSource"):

VB.NET:
Function FindInArray(ByVal MyArry() as string, ByVal strSource as string)
   For x as integer = 0 to Ubound(MyArry)
      If strSource.Contains(MyArry(x)) Then
            Return True
      End If
   Next x
   Return False
End Function
 
LINQ's Any method can handle this.

VB.NET:
        Dim MyArry() = {"This is Message one", "This is Message Two", "This is Message Three"}

        Dim Source = "This is a string that I'm searching.  This is Message Two.  Message Two is in this string"
        Dim found = MyArry.Any(Function(x) Source.Contains(x))

        Dim Source2 = "This is another string that I'm searching.  I don't have a match here."
        Dim found2 = MyArry.Any(Function(x) Source2.Contains(x))
 
Back
Top