title: Check for white space Regex C#
body: <p>I created a Regex to match the following rule :</p>
  
  <blockquote>
    <p>Must contains only upper case and numbers. Must not contains any other charaters including spacing characters (\n, \t, \v, \r, ...).</p>
  </blockquote>
  
  <p>So I created the following rule :</p>
  
  <pre><code>Regex rule = new Regex(@"^[A-Z0-9\S]+");
  </code></pre>
  
  <ul>
  <li><code>^</code> : Begin of a line / starts with</li>
  <li><code>[A-Z0-9]</code> : contains a character in upper cases, or numbers</li>
  <li><code>[\S]</code> : Doesn't contains a spacing character</li>
  <li><code>+</code> : May contains one or more occurence of the pattern</li>
  </ul>
  
  <p><em>I put a <code>@</code> character to be able to use escape character <code>\S</code>.</em></p>
  
  <p>To verify it, I created a simple WebForm, with a <code>asp:TextBox</code>, and a valid <code>asp:Button</code> to check if it is correct :</p>
  
  <p><strong>myFile.aspx</strong></p>
  
  <pre><code>&lt;asp:TextBox runat="server" ID="textBox_1"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:Button runat="server" ID="button_1" Text="Check" OnClick="button_1_Click"/&gt;
  </code></pre>
  
  <p>Then I binded the click to check if the rule is verifyied :</p>
  
  <p><strong>myFile.aspx.cs</strong></p>
  
  <pre><code>protected void button_1_Click(object sender, EventArgs e)
  {
  
      string textbox = textBox_1.Text;
      Regex rule = new Regex(@"^[A-Z0-9\S]+");            
  
      if (rule.IsMatch(textbox))
      {
          /* Match */
      }
      else
      {
          /* Doesn't match */
      }            
  }
  </code></pre>
  
  <p><strong>My problem :</strong></p>
  
  <p>When I enter the string <code>AA AA</code>, the rule is checked, which is not what I want. Did I wrote wrong my rule ?</p>
  
  <p><strong>To check the rule</strong></p>
  
  <ul>
  <li><code>AA AA</code> is not valid because it contains a spacing character</li>
  <li><code>aaaa</code> is not valid because it doesn't contains at least uppercase or number</li>
  <li><code>HELLOWORLD</code> is valid because it contains only uppercase</li>
  <li><code>HELLO654</code> is valid because it contains only uppercase or numbers</li>
  </ul>