title: .NET's Regex class and newline
body: <p>Why doesn't .NET regex treat \n as end of line character?</p>
  
  <p>Sample code:</p>
  
  <pre><code>string[] words = new string[] { "ab1", "ab2\n", "ab3\n\n", "ab4\r", "ab5\r\n", "ab6\n\r" };
  Regex regex = new Regex("^[a-z0-9]+$");
  foreach (var word in words)
  {
      Console.WriteLine("{0} - {1}", word, regex.IsMatch(word));
  }
  </code></pre>
  
  <p>And this is the response I get:</p>
  
  <pre><code>ab1 - True
  ab2
   - True
  ab3
  
   - False
   - False
  ab5
   - False
  ab6
   - False
  </code></pre>
  
  <p>Why does the regex match <code>ab2\n</code>?</p>
  
  <p><strong>Update:</strong>
  I don't think <a href="https://msdn.microsoft.com/en-us/library/yd1hzczs%28v=vs.110%29.aspx" rel="nofollow noreferrer">Multiline</a> is a good solution, that is, I want to validate login to match only specified characters, and it must be single line. If I change the constructor for MultiLine option ab1, ab2, ab3 and ab6 match the expression, ab4 and ab5 don't match it.</p>