using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<!--\[[^\]]*(?:](?!-->)[^\]]*)*]-->\R?";
string substitution = @"";
string input = @"<link rel=File-List href=""filelist.xml"">
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Revision>3</o:Revision>
<o:TotalTime>1</o:TotalTime>
<o:Created>2014-02-14T21:30:00Z</o:Created>
<o:LastSaved>2014-02-14T21:35:00Z</o:LastSaved>
<o:Pages>1</o:Pages>
<o:Words>58</o:Words>
<o:Characters>331</o:Characters>
<o:Lines>2</o:Lines>
<o:Paragraphs>1</o:Paragraphs>
<o:CharactersWithSpaces>388</o:CharactersWithSpaces>
<o:Version>15.00</o:Version>
</o:DocumentProperties>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<link rel=themeData href=""themedata.tx"">";
Regex regex = new Regex(pattern);
string result = regex.Replace(input, substitution, 1);
}
}
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