vb.net: Compare and remove strings issue

Toshiba Satellite l505d-s5965 notebook
August 27, 2015 at 22:27:31
Specs: Windows 7, 1024
Heres the code that works kinda


Dim lines As New List(Of String)
lines = RichTextBox1.Lines.ToList

Dim FilterText = TextBox1.Text


For i As Integer = lines.Count - 1 To 0 Step -1
If Regex.IsMatch(lines(i), FilterText) Then
lines.RemoveAt(i)
End If
Next

RichTextBox1.Lines = lines.ToArray

it will remove text but if the textbox has lets say
test1
test2

nothing will get removed. but
if its just test1 it will remove the string.

what am I doing wrong?

message edited by brockey01


See More: vb.net: Compare and remove strings issue

Report •


#1
August 29, 2015 at 20:18:00
"Dim FilterText = TextBox1.Text" I think this will include CRLF, but i might be wrong.

I'm not good at this, but fwiw: FilterText contains the entireity of textbox1.text, which includes CRLFs. You will need to split the FilterText on CRLF and for each resulting element, loop through the target Lines and do the RegExp remove. I think there are better ways to do this, but I don't have the "infrastructure" to set up an entire test.


Report •
Related Solutions


Ask Question