I have a string like
Deser't - & Fest !
how to format this string is seo friendly like Desert-Fest
.
In php I use the above function
function cleanString($str, $separator = "-"){
$q_separator = preg_quote($separator);
$trans = array(
'&.+?;' => '',
'[^a-z0-9 _-]' => '',
'\s+' => $separator,
'('.$q_separator.')+' => $separator
);
$str = strip_tags($str);
foreach ($trans as $key => $val){
$str = preg_replace("#".$key."#i", $val, $str);
}
$str = strtolower($str);
return trim($str, $separator);
}
How to do this in Jquery?
Thanks.