Created
March 23, 2011 15:14
-
-
Save devi/883260 to your computer and use it in GitHub Desktop.
This file contains 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 defined('SYSPATH') OR die('No direct script access.'); | |
class Valid extends Kohana_Valid { | |
public static function slug($str) | |
{ | |
if (preg_match('/^[a-zA-Z0-9_-]+$/D', $str, $matches)) | |
{ | |
// Strip multiple dashes and trim an ending or starting dashes | |
return ($str === preg_replace('/-{2,}/', '-', trim($matches[0], '-'))); | |
} | |
return FALSE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment