📜  slug 生成器 javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:51.152000             🧑  作者: Mango

代码示例2
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