Skip to content

Instantly share code, notes, and snippets.

@Abban
Created June 19, 2013 17:54
Show Gist options
  • Save Abban/5816360 to your computer and use it in GitHub Desktop.
Save Abban/5816360 to your computer and use it in GitHub Desktop.
Code To parse FB url and Twitter username
<?
protected function valid_facebook_url($field){
if(!preg_match('/^(http\:\/\/|https\:\/\/)?(?:www\.)?facebook\.com\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/', $field)){
return false;
}
return true;
}
<?
protected function valid_twitter_username($field){
if(!preg_match('/^(\@)?[A-Za-z0-9_]+$/', $field)){
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment