Lord45
Lord45

Reputation: 77

Regex vb.net match numbers with commas, \ and spaces

I am really close, I just need assistance with the first part of the regex.

Example of lines: Var=Gibberish unsigned 0,2 /e:Enum014 /ln:"Meaning" /number:695 /Gibberish:87

Var=Gibberish unsigned 2,2 /e:Gibberish /ln:"Meaning" /number:696 /Gibberish:87

"" --> total of 10 lines. For some reason, it only returns the last two lines properly and skips the first 8 (all lines are on there own line, cascading down, no spaces in a txt file).

Var=Gibberish unsigned 56,4 /e:Gibberish /ln:"Meaning" /number:4206 /Gibberish:87

Var=Gibberish unsigned 60,4 /e:Enum234 /ln:"Meaning" /number:4207 /Gibberish:88

                 Do
                    line = reader.ReadLine
                    If line Is Nothing Then Continue Do
                    m = Regex.Match(line, ".* ([0-9]+),([0-9]+) /ln:\""(.*)\"" /number:(\d+) .*")
                    If m.Groups.Count > 1 Then
                        startPosition = m.Groups(1).ToString()
                        Debug.Print(startPosition)
                        totalLength = m.Groups(2).ToString()
                        Debug.Print(totalLength)
                        ln = m.Groups(1).ToString()
                        Debug.Print(ln)
                        number = m.Groups(2).ToString()
                        Debug.Print(number)
                    End If
                Loop Until line = ""

Output: 56 4 Meaning 4206 | 60 4 Meaning 4207.

Expected 0 2 Meaning 695 | 2 2 Meaning 696 | "rest of txt file"

Upvotes: 0

Views: 127

Answers (1)

Lord45
Lord45

Reputation: 77

Thanks to Jimi, the answer is below.

.*?(\d+),(\d+).*?\""(.+?)\"".*?(\d+) .*

Upvotes: 1

Related Questions