using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} \S+ \(\S+\) - flush done sketch={flushed=(\d+) total=(\d+) pruned=(\d+)} num_org_metric=\d+ since_ms=(\d+)ms dt=[-+]?([0-9]*(\.[0-9]*)?[a-z]+)+";
string input = @"2018-03-05 22:52:52 INFO (app.go:391) - flush done sketch={flushed=264557 total=57979680 pruned=295} num_org_metric=448 since_ms=10964ms dt=2.2392s
2018-03-05 22:53:01 INFO (app.go:391) - flush done sketch={flushed=171045 total=57954960 pruned=253} num_org_metric=448 since_ms=9377ms dt=1.616403s
2018-03-05 22:53:10 INFO (app.go:391) - flush done sketch={flushed=190064 total=57933000 pruned=297} num_org_metric=448 since_ms=9366ms dt=982.968ms
2018-03-05 22:53:20 INFO (app.go:391) - flush done sketch={flushed=153243 total=57932520 pruned=89} num_org_metric=448 since_ms=9908ms dt=891.573ms";
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