title: Facebook profile URL regular expression
body: <p>Given the following Facebook profile and page URLs, my intent is to extract profile ids or usernames into the first match position.  </p>
  
  <pre><code>http://www.facebook.com/profile.php?id=123456789  
  http://www.facebook.com/someusername  
  www.facebook.com/pages/Regular-Expressions/207279373093  
  </code></pre>
  
  <p>The regex I have so far looks like this: </p>
  
  <pre><code>(?:http:\/\/)?(?:www.)?facebook.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[?\w\-]*\/)?(?:profile.php\?id=(\d.*))?([\w\-]*)?
  </code></pre>
  
  <p>Which produces the following results:</p>
  
  <p>Result 1:</p>
  
  <ol>
  <li>123456789</li>
  <li>&nbsp;</li>
  </ol>
  
  <p>Result 2:</p>
  
  <ol>
  <li>&nbsp;</li>
  <li>someusername</li>
  </ol>
  
  <p>Result 3:</p>
  
  <ol>
  <li>&nbsp;</li>
  <li>207279373093</li>
  </ol>
  
  <p>The ideal outcome would look like:</p>
  
  <p>Result 1:</p>
  
  <ol>
  <li>123456789</li>
  </ol>
  
  <p>Result 2:</p>
  
  <ol>
  <li>someusername</li>
  </ol>
  
  <p>Result 3:</p>
  
  <ol>
  <li>207279373093</li>
  </ol>
  
  <p>That is to say, I'd like to have the profile identifier to always be returned in the first position.</p>
  
  <p>It would also be ideal of <em>www.facebook.com/</em> and <em>facebook.com/</em> didn't match either.</p>