Skip to content

Instantly share code, notes, and snippets.

View jscalderons's full-sized avatar
🏠
Working from home

Jhonathan Calderon jscalderons

🏠
Working from home
  • Cali, Valle del Cauca, Colombia
View GitHub Profile
@jscalderons
jscalderons / slugify.js
Created October 23, 2017 03:04 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}