using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^""(product\stype[1234]\(\d+(?:\.\d+)?\))\s*(:.*?)?""$";
string substitution = @"$1";
string input = @"""product type1(0)""
""product type2(923)""
""product type3(10)""
""product type4(110.023) :here is a comment. It always starts with a semicolon""
""product type1(14.4):comments can be just after product entry""
""product type1(10.0) : spaces are not relevant""
""product type1(0000.01) : this kind of entry is acceptable""
""product type1(asd)""
""product type1(12a3.02)""
""product type2(0.)""
""product type2(0.123.123)""
""product type2(0...)""
""product type3(0.asd)""
""product type4(10)"" comment doesn't start with a semicolon
";
RegexOptions options = RegexOptions.Multiline;
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