public function slugify($slug)
{
// Remove HTML tags
$slug = preg_replace('/<(.*?)>/u', '', $slug);
// Remove inner-word punctuation.
$slug = preg_replace('/[\'"‘’“”\\[\\]\\(\\)\\{\\}:]/u', '', $slug);
if (craft()->config->get('allowUppercaseInSlug') === false) {
// Make it lowercase
$slug = StringHelper::toLowerCase($slug);
}
// Get the "words". Split on anything that is not a unicode letter or number. Periods, underscores, hyphens and forward slashes get a pass.
preg_match_all('/[\\p{L}\\p{N}\\.\\/_-]+/u', $slug, $words);
$words = ArrayHelper::filterEmptyStringsFromArray($words[0]);
$slug = implode(craft()->config->get('slugWordSeparator'), $words);
return $slug;
}