title: Why ^*$ matches "127.0.0.1"
body: <p>I don't understand, why does the following regular expression:</p>
  
  <pre><code>^*$
  </code></pre>
  
  <p>Match the string "127.0.0.1"? Using <code>Regex.IsMatch("127.0.0.1", "^*$");</code></p>
  
  <p>Using Expresso, it does not match, which is also what I would expect. Using the expression <code>^.*$</code> does match the string, which I would also expect.</p>
  
  <p>Technically, <code>^*$</code> should match the beginning of a string/line any number of times, followed by the ending of the string/line. It seems * is implicitly treated as a <code>.*</code></p>
  
  <p>What am I missing?</p>
  
  <p>EDIT:
  Run the following to see an example of the problem.</p>
  
  <pre><code>using System;
  using System.Text.RegularExpressions;
  
  namespace RegexFubar
  {
      class Program
      {
          static void Main(string[] args)
          {
              Console.WriteLine(Regex.IsMatch("127.0.0.1", "^*$"));
              Console.Read();
          }
      }
  }
  </code></pre>
  
  <p>I do not wish to have ^*$ match my string, I am wondering why it <strong>does</strong> match it. I would think that the expression should result in an exception being thrown, or at least a non-match.</p>
  
  <p>EDIT2:
  To clear up any confusion. I did not write this regex with the intention of having it match "127.0.0.1". A user of our application entered the expression and wondered why it matched the string when it should not. After looking at it, I could not come up with an explanation for why it matched - especially not since Expresso and .NET seems to handle it differently.</p>
  
  <p>I guess the question is answered by it being due to the .NET implementation avoiding throwing an exception, even thought it's technically an incorrect expression. But is this really what we want?</p>