using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^.*?(IDC\w*)[\s\S]*?(?:$|(,\n.*$))(\n|$)";
string substitution = @"$1\n";
string input = @" LTEXT ""Width"",IDC_WIDTH_TEXT,203,74,22,10
EDITTEXT IDC_WIDTH_IN,244,73,57,12,ES_AUTOHSCROLL | WS_GROUP
CONTROL ""Manually scale instances and paper"",IDC_RAD_PSCALE_KEYIN,
""Button"",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,15,89,132,10
CONTROL ""Keep drawing instance scale 1.0"",IDC_RAD_PSCALE_AUTO,
""Button"",BS_AUTORADIOBUTTON,15,104,123,10
CONTROL ""Keep drawing paper scale 1.0"",IDC_RAD_ISCALE_AUTO,
""Button"",BS_AUTORADIOBUTTON,15,119,118,10";
RegexOptions options = RegexOptions.Multiline | RegexOptions.IgnoreCase;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx