Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

es6 js slug from string

function slugify(string) {
  return string
    .toString()
    .trim()
    .toLowerCase()
    .replace(/s+/g, "-")
    .replace(/[^w-]+/g, "")
    .replace(/--+/g, "-")
    .replace(/^-+/, "")
    .replace(/-+$/, "");
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #slug #string
ADD COMMENT
Topic
Name
7+5 =