title: Regex for SWIFT BIC
body: <p>I have this regex to validate Swift BIC:</p>
  
  <pre><code>^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?
  </code></pre>
  
  <p>But this string is correct:</p>
  
  <pre><code>AABSDE31X-X
  </code></pre>
  
  <p>How would be the regex to match the entire optional part <code>([A-Z0-9]{3})?</code> if present?</p>
  
  <p>Thanks in advance.</p>