Compare and remove strings issue
Compare and remove strings issue
Compare and remove strings issue
Compare and remove strings issue
Compare and remove strings issue
Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue
Compare and remove strings issue Compare and remove strings issue
Compare and remove strings issue
Go Back  Xtreme Visual Basic Talk > > > Compare and remove strings issue


Reply
 
Thread Tools Display Modes
  #1  
Old 08-28-2015, 01:14 PM
Brocke Brocke is offline
Freshman
 
Join Date: Oct 2010
Posts: 41
Default Compare and remove strings issue


Code:
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?
Reply With Quote
  #2  
Old 08-28-2015, 04:33 PM
PlausiblyDamp's Avatar
PlausiblyDampCompare and remove strings issue PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

I suspect the problem could be with the regex itself rather than the code, any chance you could post examples of the regex and input strings along with actual and expected results?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 08-29-2015, 02:26 PM
Cerian Knight's Avatar
Cerian KnightCompare and remove strings issue Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,191
Default

Presuming I understand your example correctly, it seems to me that searching a single line (i) for multiple lines (test1 and test2) to match is not going to work.

You'll have to parse FilterText to its own list and then scan lines (not necessarily using RegEx) for individual matches at each index.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
Reply

Tags
remove, issue, strings, compare


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Compare and remove strings issue
Compare and remove strings issue
Compare and remove strings issue Compare and remove strings issue
Compare and remove strings issue
Compare and remove strings issue
Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue Compare and remove strings issue
Compare and remove strings issue
Compare and remove strings issue
 
Compare and remove strings issue
Compare and remove strings issue
 
-->