I have a Multi-Line text box that I can paste a list of any text items into, like this:
555-555-1212
I want's a lemon's.
google.com
1&1 Hosting
I also have a text box next to it that I can add comma separated strings that I want removed from all items in my list, like this:
-,$,!,@,#,$,%,^,&,*,(,),.com,.net,.org
I am trying to figure out how to scrub each of these strings(or whatever other strings I put in that second text box) from each of the strings in my textbox List.
Any ideas? I know how to get the List into a List-string, but not sure how to scrub that string.
This is what I have so far…but I am getting red squigglies:
List<string> removeChars = new List<string>(textBox6.Text.Split(','));
for (int i = 0; i < sortBox1.Count; i++)
{
sortBox1[i] = Regex.Replace(sortBox1[i], removeChars, "").Trim();
}
Use
String.Replaceon every string in the unwanted-list for every line inTextbox.Lines.Edit: here’s a demo: http://ideone.com/JQl79k (without windows controls since ideone doesn’t support it)