fork(1) download
  1. <?php $tests = array(
  2. 'http://f...content-available-to-author-only...k.com/walterwhite',
  3. 'https://w...content-available-to-author-only...k.com/Nightmare/profile',
  4. 'https://f...content-available-to-author-only...k.com/bacco?page=contacts',
  5. 'http://w...content-available-to-author-only...k.com/roberval',
  6. 'http://w...content-available-to-author-only...k.com/profile.php?id=Guilherme',
  7. 'http://w...content-available-to-author-only...k.com/profile.php?x=99&id=Bigown&b=389',
  8. 'http://w...content-available-to-author-only...k.com/profile.php?id=Lautert&x=99',
  9. 'http://www.google.com/search'
  10. );
  11. foreach( $tests as $test ) echo '['.fbUser( $test ).']'.PHP_EOL;
  12.  
  13. function fbUser( $url ) {
  14. $rgx = '~^https?://(www\.)?facebook.com/(?|profile\.php\?(?:.*&)*id=([^&]*)|([^/\?]*))~';
  15. if( preg_match( $rgx, $url, $matches ) ) return $matches[2];
  16. }
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
[walterwhite]
[Nightmare]
[bacco]
[roberval]
[Guilherme]
[Bigown]
[Lautert]
[]