jQuery remove special characters from string and more
Assuming by "special" you mean non-word characters, then that is pretty easy.
str = str.replace(/[_\W]+/g, "-")
replace(/[^a-z0-9\s]/gi, '')
will filter the string down to just alphanumeric values and replace(/[_\s]/g, '-')
will replace underscores and spaces with hyphens:
str.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '-')
Source for Regex: RegEx for Javascript to allow only alphanumeric
Here is a demo: http://jsfiddle.net/vNfrk/
str.toLowerCase().replace(/[\*\^\'\!]/g, '').split(' ').join('-')