title: Regex end-of-line anchor doesn't always work
body: <p>I'm working on an ASP .NET (C#) project that makes use of regular expressions and I'm having trouble with the end-of-line anchors! I'm looking for some text and I want to make sure it only occurs at the end of a string.</p>
  
  <p>Here's some sample input that demonstrates my problem. For this case I'm trying to match the word "text" at the end.</p>
  
  <blockquote>
    <p>This text is my sample text</p>
  </blockquote>
  
  <p>And here are the expressions I've tried (with the IgnoreCase option):</p>
  
  <pre><code>text\z
  text\Z
  text$
  </code></pre>
  
  <p>Now here's the crazy part. None of these regular expressions work on my system (Windows 8 Pro 64-bit, VS2010, .NET 4.0). I've debugged in my project and I've also tried the "Regex Tester" app from the Windows 8 store. It will not match!</p>
  
  <p>However, if I use an online regex tester, for example Derek Slager's at <a href="http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx" rel="nofollow">his blog post</a> which runs on .NET, or this Silverlight one at <a href="http://regexhero.net/tester/" rel="nofollow">http://regexhero.net/tester/</a>, using the exact same patterns and inputs, it matches the final instance of "text" with no problem.</p>
  
  <p>I'm confused. I really need reliable end-of-string matching and I don't know what I'm doing wrong.</p>
  
  <p>EDIT: Apparently I can't used compiled regex's. Here's an example using the data the project actually runs on:</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          string url = "http://192.168.0.113/MidlandGIS/rest/services/Osceola_Assessor_Data/MapServer/?f=pjson";
          string pattern = @"mapserver/\?f=(json|pjson)$";
  
          Regex myRegex = new Regex(pattern, RegexOptions.IgnoreCase &amp; RegexOptions.Compiled);
          Console.Write("Trying compiled regex: ");
          if (myRegex.IsMatch(url))
              Console.WriteLine("Match");
          else
              Console.WriteLine("No match.");
  
          myRegex = new Regex(pattern, RegexOptions.IgnoreCase);
          Console.Write("Trying non-compiled regex: ");
          if (myRegex.IsMatch(url))
              Console.WriteLine("Match");
          else
              Console.WriteLine("No match.");
  
          Console.Write("Trying inline regex: ");
          if (Regex.IsMatch(url, pattern, RegexOptions.IgnoreCase))
              Console.WriteLine("Match");
          else
              Console.WriteLine("No match");
  
          Console.Write("Press any key to terminate.");
          Console.ReadKey();
      }
  }
  </code></pre>
  
  <p>outputs</p>
  
  <blockquote>
    <p>Trying compiled regex: No match</p>
    
    <p>Trying non-compiled regex: Match</p>
    
    <p>Trying inline regex: Match</p>
    
    <p>Press any key to terminate.</p>
  </blockquote>
  
  <p>Edit again: OK I'm a complete idiot. I was using bitwise AND when I should be using bitwise OR to combine the regex options. Compiled regex's work just fine now.</p>