Created
December 27, 2018 16:01
-
-
Save caio-ribeiro-pereira/66462bbf20bd9c64597f1f45679f5cd4 to your computer and use it in GitHub Desktop.
Criando slug strings usando regex com prototype
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.slugify = function() { | |
return this.toLowerCase().replace(/\s/g, '-').trim(); | |
} | |
"Escrevendo JavaScript Melhor".slugify(); | |
// "escrevendo-javascript-melhor" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment