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