Last active
November 7, 2022 19:27
-
-
Save bobdobbalina/61188761985bb53b383bb20adc60df03 to your computer and use it in GitHub Desktop.
Javascript: slugify string
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
function slugify(string) { | |
return string.replace(/\W+/g, "-") | |
.replace(/[-]+$/, "") | |
.toLowerCase(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment