-1

Respected friends, I want to find the common words present at anywhere, between couple of sentences.

Str1 = “one two three four five six         seven”.
Str2 = “eight nine ten eleven two twelve six thirteen”.
Str3 = “two fourteen six fifteen sixteen seventeen eighteen”.
Result = “two six”. 

Thanks.

Aarav Hari
  • 13
  • 4
  • 3
    What have you tried so far? Provide some code samples friend. – Airn5475 Sep 13 '19 at 18:52
  • 2
    I think this question is already answered here : https://stackoverflow.com/questions/21127562/find-common-text-occurrences-in-multiple-strings – Dexirian Sep 13 '19 at 18:56
  • 1
    Possible duplicate of [Find Common text occurrences in multiple strings](https://stackoverflow.com/questions/21127562/find-common-text-occurrences-in-multiple-strings) – GSerg Sep 13 '19 at 18:58
  • This looks like the same question you already asked yesterday: https://stackoverflow.com/q/57907475/7024019 – Crusha K. Rool Sep 13 '19 at 19:33
  • Possible duplicate of [How to find common substrings in multiply text boxes which are not empty in VB.net](https://stackoverflow.com/questions/57907475/how-to-find-common-substrings-in-multiply-text-boxes-which-are-not-empty-in-vb-n) – Crusha K. Rool Sep 13 '19 at 19:35
  • Friends, the duplicate deals with two strings, and our friend here is dealing with three strings. It's may not immediately clear how one could extrapolate that answer to work with > 2 strings. – djv Sep 13 '19 at 19:50
  • Aarav, if you post some code showing what you've tried so far (maybe try out the "duplicate" too...) then you can be my friend too. – djv Sep 13 '19 at 19:51

1 Answers1

0

Here you go. This will do exactly what you asked for.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim Str1 As String = “one two three four five six         seven”
    Dim Str2 As String = “eight nine ten eleven two twelve six thirteen”
    Dim Str3 As String = “two fourteen six fifteen sixteen seventeen eighteen”
    Dim Starter As Integer = 0
    Dim CommonList As String = ""
    Dim strlist() As String

    strlist = Str1.Split(" ")
    For Starter = 0 To strlist.Length - 1
        If Str2.Contains(strlist(Starter)) Then
            If Str3.Contains(strlist(Starter)) Then
                CommonList = CommonList & " " & strlist(Starter)
            Else
            End If
        Else
        End If
    Next

    TextBox1.Text = CommonList

End Sub
Jamie
  • 555
  • 3
  • 14