“javascript str_slug” Respostas de código

Javascript Slug

var slug = "CodePadding Rahman     ( Mizan ) 12456 <> title";
slug = slug.toLowerCase().replace(/[^\w-]+/g, '-');
console.log(slug); // codepadding-rahman-mizan-12456-title
CodePadding

Javascript Slug

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
CodePadding

javascript str_slug

var slug = "şeýda şasrflar çalşaly";
//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
Embarrassed Elephant

Respostas semelhantes a “javascript str_slug”

Perguntas semelhantes a “javascript str_slug”

Mais respostas relacionadas para “javascript str_slug” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código