function convertToSlug(Text)
{
return Text
.toLowerCase()
.replace(/ /g,'-')
.replace(/[^w-]+/g,'')
;
}
function makeSlug(slug){
let finalSlug = slug.replace(/[^a-zA-Z0-9]/g, ' ');
//remove multiple space to single
finalSlug = slug.replace(/ +/g, ' ');
// remove all white spaces single or multiple spaces
finalSlug = slug.replace(/s/g, '-').toLowerCase().replace(/[^w-]+/g, '-');
return finalSlug;
}
//example of work
let slug = makeSlug('What Is a CSS Framework? (And When to Use 6 Popular Options) ')
console.log(slug) // what-is-a-css-framework---and-when-to-use-6-popular-options------------
const slugify = str =>
str
.toLowerCase()
.trim()
.replace(/[^ws-]/g, '')
.replace(/[s_-]+/g, '-')
.replace(/^-+|-+$/g, '');