“str_slug javascript” Réponses codées

slug javascript

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

slug javascript

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

str_slug javascript

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

Réponses similaires à “str_slug javascript”

Questions similaires à “str_slug javascript”

Plus de réponses similaires à “str_slug javascript” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code