java script converting text to slug
function convertToSlug(Text)
{
return Text
.toLowerCase()
.replace(/ /g,'-')
.replace(/[^\w-]+/g,'')
;
}
java script converting text to slug
function convertToSlug(Text)
{
return Text
.toLowerCase()
.replace(/ /g,'-')
.replace(/[^\w-]+/g,'')
;
}
create slug in javascript
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------------
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us