Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Oct 11th, 2008 | Syntax: VB.NET | Size: 0.92 KB | Hits: 357 | Expires: Never
Copy text to clipboard
  1. Imports System.Text.RegularExpressions
  2. Module Module1
  3.     Sub Main()
  4.         Dim sr1 As New IO.StreamReader("input.txt")
  5.         Dim strFile As String = sr1.ReadToEnd
  6.         sr1.Close()
  7.         Dim re1 As Regex = New Regex("\r\n-{30,}.*$", RegexOptions.Singleline)
  8.         If re1.IsMatch(strFile) Then
  9.             strFile = re1.Replace(strFile, "") 'remove the additional LT= sections if you want to ignore them
  10.         End If
  11.         Dim re2 As Regex = New Regex("(?<!/)(?<varname>[A-Z]+)/ *(?<varvalue>[\w ,-]+)(?= +[A-Z]+/|\r\n)|(?<varname>[A-Z#]+)= *(?<varvalue>[\w /-]+)(?= +[A-Z]+=|\r\n)")
  12.         Dim mc As MatchCollection = re2.Matches(strFile)
  13.         Dim mIdx As Integer = 0
  14.         For Each m As Match In mc
  15.             Console.WriteLine(">>>varname '" & m.Groups("varname").Value.Trim & "' contains '" & m.Groups("varvalue").Value.Trim & "'<<<")
  16.         Next
  17.         Console.WriteLine("Done.")
  18.     End Sub
  19. End Module