using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<(td) class=""headerCovTableEntryLo"">([0-9.]+)\s?%<\/\1>";
string input = @"
<head>
<meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"">
<title>LCOV - .info.cleaned</title>
<link rel=""stylesheet"" type=""text/css"" href=""gcov.css"">
</head>
<body>
<table width=""100%"" border=0 cellspacing=0 cellpadding=0>
<tr><td class=""title"">LCOV - code coverage report</td></tr>
<tr><td class=""ruler""><img src=""glass.png"" width=3 height=3 alt=""></td></tr>
<tr>
<td width=""100%"">
<table cellpadding=1 border=0 width=""100%"">
<tr>
<td width=""10%"" class=""headerItem"">Current view:</td>
<td width=""35%"" class=""headerValue"">top level</td>
<td width=""5%""></td>
<td width=""15%""></td>
<td width=""10%"" class=""headerCovTableHead"">Hit</td>
<td width=""10%"" class=""headerCovTableHead"">Total</td>
<td width=""15%"" class=""headerCovTableHead"">Coverage</td>
</tr>
<tr>
<td class=""headerItem"">Test:</td>
<td class=""headerValue"">.info.cleaned</td>
<td></td>
<td class=""headerItem"">Lines:</td>
<td class=""headerCovTableEntry"">399</td>
<td class=""headerCovTableEntry"">1019</td>
<td class=""headerCovTableEntryLo"">39.2 %</td>
</tr>
<tr>
<td class=""headerItem"">Date:</td>
<td class=""headerValue"">2016-11-07</td>
<td></td>
<td class=""headerItem"">Functions:</td>
<td class=""headerCovTableEntry"">22</td>
<td class=""headerCovTableEntry"">67</td>
<td class=""headerCovTableEntryLo"">32.8 %</td>
</tr>
<tr><td><img src=""glass.png"" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class=""ruler""><img src=""glass.png"" width=3 height=3 alt=""></td></tr>
</table>
<center>
<table width=""80%"" cellpadding=1 cellspacing=1 border=0>
<tr>
<td width=""50%""><br></td>
<td width=""10%""></td>
<td width=""10%""></td>
<td width=""10%""></td>";
foreach (Match m in Regex.Matches(input, pattern))
{
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