using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?P<reducer>\w+)\(\)\s+of\s+query\((?P<dashboardUID>\w+)\/(?P<panelID>\d+)\/(?P<metric>.+),\s+(?P<from>\w+),\s+(?P<to>\w+)\)\s+is\s+(?P<evaluator>\w+)\((?P<params>-*\d*[\.,\s]*\d*\w*)\)\s*(for\s+\((?P<for>\w+)\))*\s*(every\((?P<every>\w+)\))*\s*$";
string input = @"avg() of query(wpFnYRwGk/2/bitrate, 15m, now) is below(14)
avg() of query(wpFnYRwGk/2/bitrate, 15m, now) is below(0.4)
avg() of query(wpFnYRwGk/2/bitrate, 15m, now) is novalue()
avg() of query(wpFnYRwGk/2/bitrate, 15m, now) is withinrange(4, 88)
avg() of query(wpFnYRwGk/2/bitrate, 15m, now) is withinrange(4, 88) for (1m)
avg() of query(wpFnYRwGk/2/bitrate, 15m, now) is withinrange(4, 88) for (1m) every(1m)
avg() of query(summary/152/tx-avg, 1m, now) is below(5000)
avg() of query(summary/152/tx-avg, 1m, now) is below(-5000)
avg() of query(wpFnYRwGk/2/bitrate, 15m, now) is above(300M)";
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