Skip to content

Instantly share code, notes, and snippets.



Last active Jan 10, 2016
What would you like to do?
Replace special chars with hyphen.
function hyphenize(string) {
string = string.replace(/[^A-Za-z0-9\. -]/g, '');
return string.replace(/ */g, '-');
var str = "Nike The Future One / Interactive Setting"
// "Nike-The-Future-One-Interactive-Setting"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.