title: using static Regex.IsMatch vs creating an instance of Regex
body: <p>In C# should you have code like:</p>
  
  <pre><code>public static string importantRegex = "magic!";
  
  public void F1(){
    //code
    if(Regex.IsMatch(importantRegex)){
      //codez in here.
    }
    //more code
  }
  public void main(){
    F1();
  /*
    some stuff happens......
  */
    F1();
  }
  </code></pre>
  
  <p>or should you persist an instance of a Regex containing the important pattern? What is the cost of using Regex.IsMatch? I imagine there is an NFA created in each Regex intance. From what I understand this NFA creation is non trivial. </p>