Answers for "sluginfy string in js"

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