using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(counter|histogram)[.]_*[a-z]+[a-z_0-9]*[.]_*[a-z]+[a-z_0-9]*";
string input = @"counter..
counter. .
counter.a.b
counter._._
counter._a._
counter._._a
counter._a._a
counter._1._1
counter._a1._a1
counter.system.crashes
counter.system_server.crashes
counter.system_server2.crashes_
counter.system_server2._crashes_
counter.system_server2._crashes_1
counter.system_server2._crashes_2
counter.2system_server.2crashes
counter.2system_server.crashes2
counter.system_server.crashes_2
counter.system_server._crashes_2
counter.system_server.2_crashes_2
counter.scheduler.jobs_delayed
counter.scheduler.jobs_delayed2
counter.scheduler_.jobs_delayed_
counter.scheduler._jobs_delayed_
counter.scheduler.jobs_delayed_
histogram.scheduler.jobs_delayed";
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