Method I Wish Was There: Regex

I don’t want to have to pull in System.Text.RegularExpression every time I want a new Regex. Perl, boo, awk and javascript just say // for regex. In C#, I can just say “abc\d{3}”.Regex().

public static System.Text.RegularExpressions.Regex Regex(this string source)
{
  return new System.Text.RegularExpressions.Regex(source);
}

Now I can write:

if (“there are (\d+) lights”.Regex().Match().Groups[1].Value > 0) …