title: java regex allow optional space character
body: <p>I am trying to create a regex pattern to match <code>abcdef</code>, <code>abc def</code>, etc.</p>
  
  <p>The patterns I tried are:</p>
  
  <pre><code>[a-z]{3}[\s?][a-z]{3}
  [a-z]{3}[\s*][a-z]{3}
  [\w]{3}[\s?][\w]{3}
  \w{3}\s?\w{3}
  </code></pre>
  
  <p>All of these seem to work for <code>abc def</code>, but not for <code>abcdef</code>.</p>
  
  <p>{EDIT}</p>
  
  <pre><code>AB CD 12 ABC/15 DEF
  .*\bAB CD\b\s?(\d+)\s?\bABC\b[/](\d+)\s?\bDEF\b
  </code></pre>
  
  <p>i am trying to extract 12 and 15.</p>