using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<!--block:(.*?)-->((?:(?:(?!<!--(.*?)-->).)|(?R))*?)<!--endblock-->";
string input = @"<!DOCTYPE html><html><head><title>Crew Watch (Responses)</title>
<link href='/static/spreadsheets2/client/css/461985016-waffle_k_ltr.css' type='text/css' rel='stylesheet'><style type=""text/css"">
html { overflow: visible; }
#sheets-viewport { overflow: auto; }
#sheets-viewport.widget-viewport { overflow: hidden; }
.grid-container { overflow: visible; background: white;}
.grid-table-container { overflow: visible; }
#top-bar {
background: url(""//ssl.gstatic.com/docs/spreadsheets/publishheader.png"") repeat-x bottom;
margin: 0;
overflow: hidden;
}
#top-bar {
border-bottom: 1px solid #ccc;
padding: 6px 6px 0;
}
#doc-title { padding-bottom: 5px; }
#doc-title .name { font-size: 15px; }
#sheet-menu {
font-size: 13px;
margin: 6px 0 0;
padding: 0 0 5px;
}
#sheet-menu li {
display: inline;
list-style-type: none;
margin: 0;
padding: 5px 8px;
}
#sheet-menu li.active {
background-color: #fff;
font-weight: bold;
border: 1px solid #999;
}
#top-bar #sheet-menu li.active {
border-bottom: 0;
}
#sheet-menu a, #sheet-menu a:visited { color: #07c; }
.ritz .waffle .s0{text-align:left;color:#000000;background-color:#ffffff;font-family:arial,sans,sans-serif;font-size:10pt;vertical-align:bottom;white-space:nowrap;direction:ltr;padding:2px 3px 2px 3px;}.ritz .waffle .s1{text-align:right;color:#000000;background-color:#ffffff;font-family:arial,sans,sans-serif;font-size:10pt;vertical-align:bottom;white-space:nowrap;direction:ltr;padding:2px 3px 2px 3px;}</style><script type=""text/javascript"">
var activeSheetId;
function switchToSheet(id) {
if (document.getElementById('sheet-menu')) {
document.getElementById('sheet-button-' + activeSheetId)
.className = '';
document.getElementById('sheet-button-' + id).className = 'active';
}
document.getElementById(activeSheetId).style.display = 'none';
document.getElementById(id).style.display = '';
activeSheetId = id;
// posObjs() is defined in embeddedObjectJs (see EmbeddedObjectHtmlBuilder.java)
posObjs();
return false;
}
function init() {
var optPageSwitcher;
function resize() {
var optTopBar = document.getElementById('top-bar');
var adjustedHeight = window.innerHeight - (optTopBar ? optTopBar.offsetHeight : 0);
var adjustedWidth = window.innerWidth;
var sheetsViewport = document.getElementById('sheets-viewport');
sheetsViewport.style.width = (adjustedWidth + 'px');
sheetsViewport.style.height = (adjustedHeight + 'px');
if (optPageSwitcher) {
optPageSwitcher.resize(adjustedWidth, adjustedHeight);
}
}
resize();
window.onresize = resize;
}
</script></head><body onload=init()><div id=""top-bar""><div id=""doc-title""><span class=""name"">Crew Watch (Responses) : Form Responses 1</span></div></div><div id=""sheets-viewport""><div id=""1416730418"" style=""display:none;position:relative;"" dir=""ltr""><div class=""ritz grid-container"" dir=""ltr""><table class=""waffle"" cellspacing=""0"" cellpadding=""0""><thead><tr><th class=""row-header freezebar-vertical-handle header-shim row-header-shim""></th><th id=""1416730418C0"" style=""width:150px"" class=""header-shim""></th><th id=""1416730418C1"" style=""width:150px"" class=""header-shim""></th><th id=""1416730418C2"" style=""width:150px"" class=""header-shim""></th><th id=""1416730418C3"" style=""width:150px"" class=""header-shim""></th><th id=""1416730418C4"" style=""width:150px"" class=""header-shim""></th><th id=""1416730418C5"" style=""width:150px"" class=""header-shim""></th><th id=""1416730418C6"" style=""width:150px"" class=""header-shim""></th><th id=""1416730418C7"" style=""width:150px"" class=""header-shim""></th><th id=""1416730418C8"" style=""width:150px"" class=""header-shim""></th></tr></thead><tbody><tr style='height:21px;'><th id=""1416730418R0"" style=""height: 21px;"" class=""row-headers-background row-header-shim""><div class=""row-header-wrapper"" style=""line-height: 21px;"">1</div></th><td class=""s0"">Timestamp</td><td class=""s0"">First Name</td><td class=""s0"">Middle Name</td><td class=""s0"">Last Name</td><td class=""s0"">Date of Birth</td><td class=""s0"">Street Address</td><td class=""s0"">City</td><td class=""s0"">State</td><td class=""s0"">Zip Code</td></tr><tr><th style=""height:4px"" class=""freezebar-cell freezebar-horizontal-handle row-header-shim""></th><td class=""freezebar-cell""></td><td class=""freezebar-cell""></td><td class=""freezebar-cell""></td><td class=""freezebar-cell""></td><td class=""freezebar-cell""></td><td class=""freezebar-cell""></td><td class=""freezebar-cell""></td><td class=""freezebar-cell""></td><td class=""freezebar-cell""></td></tr><tr style='height:21px;'><th id=""1416730418R1"" style=""height: 21px;"" class=""row-headers-background row-header-shim""><div class=""row-header-wrapper"" style=""line-height: 21px;"">2</div></th><td class=""s1"" dir=""ltr"">3/26/2014 21:33:20</td><td class=""s0"" dir=""ltr"">John</td><td class=""s0"" dir=""ltr"">Collier</td><td class=""s0"" dir=""ltr"">Armstrong</td><td></td><td></td><td></td><td></td><td></td></tr><tr style='height:21px;'><th id=""1416730418R2"" style=""height: 21px;"" class=""row-headers-background row-header-shim""><div class=""row-header-wrapper"" style=""line-height: 21px;"">3</div></th><td class=""s1"" dir=""ltr"">8/21/2014 0:56:02</td><td class=""s0"" dir=""ltr"">john</td><td class=""s0"" dir=""ltr"">collier</td><td class=""s0"" dir=""ltr"">armstrong</td><td class=""s1"" dir=""ltr"">1/10/1984</td><td class=""s0"" dir=""ltr"">4720 SW 21st St.</td><td class=""s0"" dir=""ltr"">Topeka</td><td></td><td class=""s1"" dir=""ltr"">66604</td></tr><tr style='height:21px;'><th id=""1416730418R3"" style=""height: 21px;"" class=""row-headers-background row-header-shim""><div class=""row-header-wrapper"" style=""line-height: 21px;"">4</div></th><td class=""s1"" dir=""ltr"">9/11/2014 0:56:28</td><td class=""s0"" dir=""ltr"">Conner</td><td class=""s0"" dir=""ltr"">Goss</td><td class=""s0"" dir=""ltr"">Griffin</td><td class=""s1"" dir=""ltr"">8/31/1992</td><td></td><td class=""s0"" dir=""ltr"">Topeka</td><td></td><td></td></tr></tbody></table></div></div></div>
<script type='text/javascript'>
function posObj(sheet, id, row, col, x, y) {
var r = document.getElementById(sheet+'R'+row);
var c = document.getElementById(sheet+'C'+col);
if (r && c) {
var s = document.getElementById(id).style;
var t = y;
while (r) {
t += r.offsetTop;
r = r.offsetParent;
}
var l = x;
while (c) {
l += c.offsetLeft;
c = c.offsetParent;
}
s.left = l + 'px';
s.top = t + 'px';
s.display = 'block';
s.border = '1px solid #000000';
}
};
function posObjs() {
};
posObjs();</script>
<script type=""text/javascript"">activeSheetId = '1416730418'; switchToSheet('1416730418');</script></body></html>";
RegexOptions options = RegexOptions.Singleline;
Match m = Regex.Match(input, pattern, options);
Console.WriteLine("'{0}' found at index {1}", m.Value, m.Index);
}
}
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