title: C# regular expression to match square brackets
body: <p>I'm trying to use a regular expression in C# to match a software version number that can contain:</p>
  
  <ul>
  <li>a 2 digit number</li>
  <li>a 1 or 2 digit number (not starting in 0)</li>
  <li>another 1 or 2 digit number (not starting in 0)</li>
  <li>a 1, 2, 3, 4 or 5 digit number (not starting in 0)</li>
  <li>an option letter at the end enclosed in square brackets.  </li>
  </ul>
  
  <p>Some examples:</p>
  
  <pre>
  10.1.23.26812
  83.33.7.5
  10.1.23.26812[d]
  83.33.7.5[q]
  </pre>
  
  <p>Invalid examples:</p>
  
  <pre>
  10.1.23.26812[
  83.33.7.5]
  10.1.23.26812[d
  83.33.7.5q
  </pre>
  
  <p>I have tried the following:</p>
  
  <pre><code>string rex = @"[0-9][0-9][.][1-9]([0-9])?[.][1-9]([0-9])?[.][1-9]([0-9])?([0-9])?([0-9])?([0-9])?([[][a-zA-Z][]])?";
  </code></pre>
  
  <p>(note: if I try without the "@" and just escape the square brackets by doing "\["  I get an error saying "Unrecognised escape sequence")</p>
  
  <p>I can get to the point where the version number is validating correctly, but it accepts anything that comes after (for example: "10.1.23.26812thisShouldBeWrong" is being matched as correct).</p>
  
  <p>So my question is: is there a way of using a regular expression to match / check for square brackets in a string or would I need to convert it to a different character (eg: change [a] to <em>a</em> and match for *s instead)?</p>