using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"TOTAL.*?(\d+)%";
string input = @"Name Stmts Miss Cover Missing
---------------------------------------------------------------
src/global_information.py 8 1 88% 6
src/settings.py 38 0 100%
src/storage_backends.py 4 4 0% 1-5
src/urls.py 8 0 100%
users/admin.py 1 0 100%
users/apps.py 3 3 0% 1-5
users/forms.py 5 0 100%
users/models.py 1 0 100%
users/tests/tests_views_urls.py 5 0 100%
users/urls.py 5 0 100%
users/views.py 1 1 0% 1
---------------------------------------------------------------
TOTAL 79 9 89%
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(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