Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
Source by www.30secondsofcode.org #
 
PREVIOUS NEXT
Tagged: #slug #javascript
ADD COMMENT
Topic
Name
4+6 =