Skip to content

Instantly share code, notes, and snippets.

@sundarj
Forked from mathewbyrne/slugify.js
Last active April 24, 2016 20:41
Show Gist options
  • Select an option

  • Save sundarj/0f319b66d6916988e5ba to your computer and use it in GitHub Desktop.

Select an option

Save sundarj/0f319b66d6916988e5ba to your computer and use it in GitHub Desktop.
Javascript Slugify (works with unicode chars)
function slugify( title ) {
return (title+'')
.toLowerCase()
.replace(/\s+/g, '-')
.replace(/[!"'£$%\^&*()_+=\/\|`¬/><.,{}[\]:;]/g, '')
.replace(/\-\-+/g, '-')
.replace(/^-+/, '')
.replace(/-+$/, '')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment