I’ve been struggling with this for hours now, and granted I have issues with RegEx anyways, but no matter what I can’t seem to find my error. My purpose is to be able to have portions of lines that are on the clipboard stripped out, pasting only the remaining portion into various textboxes. The format on the clipboard is:
Heading: Information
Heading: Information
Information
Heading: Information
etc,etc,etc
I need only the information to remain, stripping the Header, colon, and whitespaces off. The code I have thus far is:
string[] lines = null;
object obj = this.Parent;
StackPanel parent = (StackPanel)obj;
ChildControls ccChildren = new ChildControls();
if (Clipboard.GetText().Contains('='))
{
}
else if (Clipboard.GetText().Contains(':'))
{
string filterLabels = @"(?!\:)([^\:]*)$";
lines = Regex.Split(Clipboard.GetText(), "\r\n");
List<string> linesList = new List<string>(lines);
foreach (string line in linesList)
{
Regex.Replace(line, filterLabels, "");
}
}
else
{
lines = Regex.Split(Clipboard.GetText(), "\r\n");
}
The RegEx in filterLabels I got from playing with RegExBuddy, and according to that it should work fine. But in reality it doesn’t strip anything at all. Anyone catch something I’m missing?
Just realized I never accepted an answer on this, and I thought I’d post my final solution for anyone else that has a similar problem. Ultimately I took bits and pieces from several of these answers, and came up with this: