function urlify( str ) {
return str
.toLowerCase()
.replace(/[^a-z0-9]+/gi, '-') // limpa caracteres
.replace(/-{2,}/g, '-') // remove - duplas
.replace(/^-|-$/g, '' ); // remove - do inicio e fim
}
Simple URLify JS
1 Response
Thank you
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.