-
-
Save wpsmith/406cd6cc40c469f6bec1 to your computer and use it in GitHub Desktop.
A simple facebook URL checker RegEx for PHP or JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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