using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @".*<!--StartFragment-->(.*)<!--EndFragment-->.*";
string substitution = @"$1";
string input = @"---------------------------
ahk html clipboard.ahk
---------------------------
Version:0.9
StartHTML:0000000159
EndHTML:0000002912
StartFragment:0000000195
EndFragment:0000002876
SourceURL:https://en.wikipedia.org/wiki/Genghis_Khan
<html>
<body>
<!--StartFragment--><b style=""color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;"">Genghis Khan</b><span style=""color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;""><span> </span>or<span> </span></span><b style=""color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;"">Chinggis Khaan</b><sup id=""cite_ref-7"" class=""reference"" style=""line-height: 1; unicode-bidi: isolate; white-space: nowrap; font-size: 11.2px; font-weight: 400; font-style: normal; color: rgb(34, 34, 34); font-family: sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;""><a href=""https://en.wikipedia.org/wiki/Genghis_Khan#cite_note-7"" style=""text-decoration: none; color: rgb(11, 0, 128); background: none;"">[note 3]</a></sup><span style=""color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;""><span> </span>(c. 1162 – August 18, 1227),</span><!--EndFragment-->
</body>
</html>
---------------------------
OK
---------------------------
";
RegexOptions options = RegexOptions.Singleline;
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