title: preg_match, find and extract
body: <p>I'm using this to determine if a string looks like the right url, and then extract a value</p>
  
  <pre><code>if (preg_match('#^(https?:\/\/)?(www.)?site.com\/cat\/(aaa\d{5,30})\/#', $url, $urlid)) {
  
     echo $urlid[3];
  
  }
  </code></pre>
  
  <p>It works ok, but I think it could be more lean/improved (or just more good-practice). Should I add some "negative look-ahead", "non-capturing" or other?</p>
  
  <p>This for example <code>(https?:\/\/)?(www.)?</code> was just a quick thought. It works, but... Should it really be in parentheses or is there a better way?</p>