title: C# Regex Validation Rule using Regex.Match()
body: <p>I've written a Regular expression which should validate a string using the following rules:</p>
  
  <ol>
  <li>The first four characters must be alphanumeric. </li>
  <li>The alpha characters are followed by 6 or 7 numeric values for a total length of 10 or 11.</li>
  </ol>
  
  <p>So the string should look like this if its valid:</p>
  
  <blockquote>
    <p>CCCCNNNNNN or CCCCNNNNNNN</p>
  </blockquote>
  
  <p>C being any character and N being a number.</p>
  
  <p>My expression is written: <code>@"^[0-9A-Za-z]{3}[0-9A-Za-z-]\d{0,21}$";</code></p>
  
  <p>My regex match code looks like this:</p>
  
  <pre><code>var cc1 = "FOOBAR"; // should fail.
  var cc2 = "AAAA1111111111"; // should succeed
  
  var regex = @"^[0-9A-Za-z]{3}[0-9A-Za-z-]\d{0,21}$";
  
  Match match = Regex.Match( cc1, regex, RegexOptions.IgnoreCase );
  
  if ( cc1 != string.Empty &amp;&amp; match.Success )
  {
       //"The Number must start with 4 letters and contain no numbers.",
       Error = SeverityType.Error
  }
  </code></pre>
  
  <p>I'm hoping someone can take a look at my expression and offer some feedback on improvements to produce a valid match.</p>
  
  <p>Also, am I use <code>.Match()</code> correctly? If <code>Match.Success</code> is <code>true</code>, then does that mean that the string is valid? </p>