I am trying to parse junk and narrow down a bunch of text. How do I delete the current line if a does not match? I would like to remove the line entirely:
For i As Integer = 0 To RichTextBox1.Lines.Length - 1
Dim a As String = RichTextBox1.Lines(i).ToString
If Not a = "SaveThisLine" Then
'delete the active line
End If
Next
Also how would I match partially? Such as if not a = "SaveThisLine" & * (to use a wildcard).
I would not touch original text and rather save valid lines into a
StringBuilder, so if line is valid,AppendLineto it. In the end dump back intoRichTextBox1.TextusingStringBuilder.ToString.For partial match in VB.NET you can use a native
Likeoperator:Returns
True.Or use regular expressions:
Also returns
True.