title: Regex how to match an optional character
body: <p>I have a regex that I thought was working correctly until now. I need to match on an optional character. It may be there or it may not.</p>
  
  <p>Here are two strings. The top string is matched while the lower is not. The absence of a single letter in the lower string is what is making it fail.</p>
  
  <p>I'd like to get the single letter after the starting 5 digits if it's there and if not, continue getting the rest of the string. This letter can be <code>A-Z</code>.</p>
  
  <p>If I remove <code>([A-Z]{1}) +.*? +</code> from the regex, it will match everything I need except the letter but it's kind of important.</p>
  
  <pre><code>20000      K               Q511195DREWBT            E00078748521
  30000                      K601220PLOPOH            Z00054878524
  </code></pre>
  
  <p>Here is the regex I'm using.</p>
  
  <pre><code>/^([0-9]{5})+.*? ([A-Z]{1}) +.*? +([A-Z]{1})([0-9]{3})([0-9]{3})([A-Z]{3})([A-Z]{3}) +([A-Z])[0-9]{3}([0-9]{4})([0-9]{2})([0-9]{2})/
  </code></pre>