Answers for "javascript slugify"

2

java script converting text to slug

function convertToSlug(Text)
{
    return Text
        .toLowerCase()
        .replace(/ /g,'-')
        .replace(/[^\w-]+/g,'')
        ;
}
Posted by: Guest on July-08-2020
0

es6 js slug from string

function slugify(string) {
  return string
    .toString()
    .trim()
    .toLowerCase()
    .replace(/\s+/g, "-")
    .replace(/[^\w\-]+/g, "")
    .replace(/\-\-+/g, "-")
    .replace(/^-+/, "")
    .replace(/-+$/, "");
}
Posted by: Guest on November-22-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language