Get each string from each list

0

From a text file with several strings I transform them to a list and I need to compare each word to know if the elements of that list match the elements of another list something like a lexical analyzer.

The problem is that when I try to call a foreach string I can not capture it.

    Dim ruta = My.Computer.FileSystem.SpecialDirectories.Desktop & "Pequeno.txt"
    Dim rutaRes = My.Computer.FileSystem.SpecialDirectories.Desktop & "Reservadas.txt"
    Dim rutaOP = My.Computer.FileSystem.SpecialDirectories.Desktop & "Operadores.txt"

    Dim names1 As String() = System.IO.File.ReadAllLines(ruta)
    Dim names2 As String() = System.IO.File.ReadAllLines(rutaOP)
    Dim names3 As String() = System.IO.File.ReadAllLines(rutaOP)


    For Each Email As String In names1
        Dim queryS = Email.Except(names2)
    Next

    Dim Query1 = names1.Except(names2)
    Dim Query2 = names1.Except(names2)

    Dim querRes = Query1.Except(names1)
    Dim querOp = Query1.Except(names1)
    
asked by Cris Valdez 20.06.2017 в 18:10
source

1 answer

1

If I understand you correctly and with some small corrections your code would be like this:

Dim ruta = My.Computer.FileSystem.SpecialDirectories.Desktop & "\Pequeno.txt"
Dim rutaRes =My.Computer.FileSystem.SpecialDirectories.Desktop &"\Reservadas.txt"
Dim rutaOP = My.Computer.FileSystem.SpecialDirectories.Desktop &"\Operadores.txt"

Dim names1 As String() = System.IO.File.ReadAllLines(ruta)
Dim names2 As String() = System.IO.File.ReadAllLines(rutaRes)
Dim names3 As String() = System.IO.File.ReadAllLines(rutaOP)

Dim intersect As IEnumerable(Of String) = names1.Intersect(names2)
Dim Duplicados As New Text.StringBuilder

For Each Email In intersect
    Duplicados.AppendLine(Email)
Next

in the files Pequeno I have this text: euro dollar weight Sun bolivar tolar manat pound crown ruble

and in Reserved: crown tolar weight ruble euro

the results of the duplicates are: euro weight tolar crown ruble

    
answered by 30.06.2017 / 01:08
source