Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Forked from atomicpages/fbUrlCheck.php
Last active October 9, 2015 12:21
Show Gist options
  • Select an option

  • Save wpsmith/406cd6cc40c469f6bec1 to your computer and use it in GitHub Desktop.

Select an option

Save wpsmith/406cd6cc40c469f6bec1 to your computer and use it in GitHub Desktop.
A simple facebook URL checker RegEx for PHP or JavaScript
<?php
/**
* A simple regex to test whether or not a facebook url is valid. For basic usage, this will do the job.
* @see Test cases <http://ideone.com/ZMJp4f>
*/
function fbUrlCheck( $url ) {
if ( preg_match( '/^(https?:\/\/)?(www\.)?facebook.com\/[a-zA-Z0-9(\.\?)?]/', $url ) == 1 && preg_match( '/home((\/)?\.[a-zA-Z0-9])?/', $url ) == 0 ) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment