title: Regex for validating a website address in ASP.NET
body: <p>When I use a regex validator on a page with the following regular expression:</p>
  
  <pre><code>&lt;asp:RegularExpressionValidator ID="regexWebsiteValidator" runat="server" ControlToValidate="ctlWS" ValidationExpression="(http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ;,./?%&amp;=]*)?" ErrorMessage="Invalid Website Address!" /&gt;
  </code></pre>
  
  <p>and enter <code>http://www,google.com</code> in the textbox,
  the validation fails as expected. </p>
  
  <p>If I use the same regex but try to match it using Regex.Match, it passes. Can someone tell me what I am doing wrong?</p>
  
  <pre><code>string strRegex = @"(http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ;,./?%&amp;=]*)?";
  bool b = System.Text.RegularExpressions.Regex.Match("http://www,google.com", strRegex).Success;
  </code></pre>
  
  <p>b is <code>true</code>!</p>