title: preg_match substring only if is valid
body: <p>I need to extract a substring from an email subject only if valid. The valid substring is like:</p>
  
  <p><code>ab-2011-0023ad</code> or <code>ac-2011-0023ad.r1</code>, only two dashes are allowed, number of letters after second dash varies, but only alphanumeric with one dot or without dot.</p>
  
  <p>I wrote this one, but if I put after second dash an illegal character, the regexp returns partial substring not empty</p>
  
  <pre><code>/([a-z0-9]{0,3}[-]\d{4}[-][a-z0-9.]+)\S/i
  </code></pre>
  
  <p>i.e.: <code>"this is an email with ab-2011-0023:ad document"</code>, I expect from regexp to return empty array not <code>[0] =&gt; ab-2011-0023</code>.</p>