“Str_slug Javascript” Kode Jawaban

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

Jawaban yang mirip dengan “Str_slug Javascript”

Pertanyaan yang mirip dengan “Str_slug Javascript”

Lebih banyak jawaban terkait untuk “Str_slug Javascript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya