Created
June 19, 2011 07:56
-
-
Save devi/1033909 to your computer and use it in GitHub Desktop.
slug/permalink validation
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 | |
| // lower alpha | |
| // alnum followed by alnum or hyphen between alnum | |
| function valid_slug1($value) | |
| { | |
| return (bool) preg_match('/^[a-z0-9]+(-[a-z0-9]+)*$/iD', (string) $value); | |
| } | |
| // alpha followed by alnum or hyphen between alnum | |
| function valid_slug2($value) | |
| { | |
| return (bool) preg_match('/^[a-z]+(-?[a-z0-9]+)*$/iD', (string) $value); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment