using System.Text.RegularExpressions;
using System.Diagnostics;
public static void Main()
Console.WriteLine("Hello World");
var values = Enumerable.Range(1, 10000)
.Concat(Enumerable.Range(1, 10000).Select(x=>"Value1"+x + "+"))
.Concat(Enumerable.Range(1, 10000).Select(x=>"+Value1"+x + "+"))
var sw = new Stopwatch();
foreach (var value in values){
Console.WriteLine("Regex ({0}/{1}/{2}): {3}", ok, failed, values.Length, sw.Elapsed);
foreach (var value in values){
Console.WriteLine("Regex Initialized ({0}/{1}/{2}): {3}", ok, failed, values.Length, sw.Elapsed);
foreach (var value in values){
Console.WriteLine("Regular ({0}/{1}/{2}): {3}", ok, failed, values.Length, sw.Elapsed);
foreach (var value in values){
Console.WriteLine("Regular Second ({0}/{1}/{2}): {3}", ok, failed, values.Length, sw.Elapsed);
static Regex rgAlphaNumOrHyphen = new Regex("^[a-zA-Z0-9-]+$", RegexOptions.Compiled);
public static bool RegexMatch(string value){
return rgAlphaNumOrHyphen.IsMatch(value);
public static bool Match(string value){
if(value.Length==0){return false;}
for (int i = 0, count = value.Length; i<count; i++){
if (c>='a' && c<='z'){continue; }
if (c>='A' && c<='Z'){continue;}
if (c>='0' && c<='9'){continue;}