var slug = "CodePadding Rahman ( Mizan ) 12456 <> title";
slug = slug.toLowerCase().replace(/[^w-]+/g, '-');
console.log(slug); // codepadding-rahman-mizan-12456-title
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, '');
var slug = "CodePadding Rahman ( Mizan ) 12456 <> title";
//change all characters except numbers and letters
slug = slug.replace(/[^a-zA-Z0-9]/g, ' ');
//remove multiple space to single
slug = slug.replace(/ +/g, ' ');
// remove all white spaces single or multiple spaces
slug = slug.replace(/s/g, '-').toLowerCase();
console.log(slug)
// output - codepadding-rahman-mizan-12456-title
function makeSlug(slug){
return slug.toLowerCase().replace(/[^w-]+/g, '-');
}
let slug = makeSlug("CodePadding Rahman ( Mizan ) 12456 <> title")