public void TestEvilRegex()
{
Regex EvilRegex = new Regex(@"^(([a-z])+.)+[A-Z]([a-z])+$", RegexOptions.Compiled | (RegexOptions.Singleline));
string a = "aaaaaaaaaaaaaaaaaaa";
//takes time exponential in the length of a
int t = 0;
for (int i = 0; i < 15; i++)
{
t = System.Environment.TickCount;
EvilRegex.IsMatch(a);
t = System.Environment.TickCount - t;
TestContext.WriteLine("{0}, {1}", a.Length, t);
a += "a";
}
Assert.IsTrue(t > 1000);
}