Skip to content

Instantly share code, notes, and snippets.

@caio-ribeiro-pereira
Created December 27, 2018 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caio-ribeiro-pereira/66462bbf20bd9c64597f1f45679f5cd4 to your computer and use it in GitHub Desktop.
Save caio-ribeiro-pereira/66462bbf20bd9c64597f1f45679f5cd4 to your computer and use it in GitHub Desktop.
Criando slug strings usando regex com prototype
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