using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?=[^P]*(?:ParNew|P.*ParNew|PSYoungGen|DefNew)).*?(?P<ParNew_before_1>\d+)K->(?P<ParNew_after_1>\d+)K\((?P<young_heap_size>\d+)K\), (?P<par_new_duration>\d+\.\d+) secs\] (?P<ParNew_before_2>\d+)K\->(?P<ParNew_after_2>\d+)K\((?P<total_heap_size>\d+)";
string input = @"146372.273: [GC146372.274: [ParNew: 378633K->88155K(419456K), 0.0313803 secs] 9893391K->9602913K(12478080K), 0.0320299 secs] [Times: user=0.32 sys=0.01, real=0.03 secs]
2017-05-12T10:35:46.076+0000: 2.799: [GC2017-05-12T10:35:46.076+0000: 2.800: [ParNew: 409024K->51072K(460096K), 0.3273966 secs] 409024K->121051K(2046080K), 0.3275292 secs] [Times: user=0.31 sys=0.07, real=0.33 secs]
";
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