Regex

aeolian20

Member
Joined
Feb 13, 2010
Messages
12
Programming Experience
Beginner
Hello, can someone please check my Regex to see where I am faulting.

I am finding lines that being with

COMMAND
GO TO PAGE
TRK
VIEW

I am trying to delete these lines & the 3 lines above & below. It works sometimes but not in all instances. Thanks.

VB.NET:
Dim RichTextBoxReadOnlyStateBoolean = Me.RichTextBox3.ReadOnly
        Me.RichTextBox3.ReadOnly = False

        Dim myTextosslog As New String(Me.WebBrowser3.Document.Body.InnerText)
        Me.RichTextBox3.Text = myTextosslog

        'Remove Redundant Lines
        Dim logs As MatchCollection = Regex.Matches(Me.RichTextBox3.Text, "((^|\n).*){3}\n.+COMMAND.*\n.+GO TO PAGE.*\n.+TRK.*\n.+VIEW.*((^|\n).*){3}")
        For i As Integer = logs.Count - 1 To 0 Step -1
            Dim m As Match = logs(i)
            Me.RichTextBox3.Select(m.Index, m.Length)
            Me.RichTextBox3.SelectedText = String.Empty

        Next
 
I think I may have found a solution:

VB.NET:
"((^|\n).*){3}\n.+COMMAND.*\n.+GO TO PAGE.*\n.+TRK.*\n.+VIEW.*(\n.*){2}\n"
 
Back
Top