Skip to content

Instantly share code, notes, and snippets.

@buchizo
Created July 21, 2012 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buchizo/3154817 to your computer and use it in GitHub Desktop.
Save buchizo/3154817 to your computer and use it in GitHub Desktop.
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// http://d.hatena.ne.jp/n_shuyo/touch/20111020/regular_expression
var pattern = @"[-_.0-9A-Za-z]+@[-_0-9A-Za-z]+[-_.0-9A-Za-z]+";
var reg = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);
string dummy = repeat("abcdefg", 2000);
Stopwatch sw = new Stopwatch();
sw.Start();
Console.WriteLine(reg.IsMatch(dummy));
sw.Stop();
Console.WriteLine(sw.Elapsed);
Console.ReadKey();
}
public static String repeat(String st, int c)
{
string buf = "";
for (int i = 0; i < c; ++i) buf += st;
return buf;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment