Created
June 13, 2018 08:49
-
-
Save benwhalley/592495ecf45b0bfee7b1332dd4ac31df to your computer and use it in GitHub Desktop.
Make strings url and filename friendly (akin to Django's eponymous function)
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
slugify <- function(text){ | |
text %>% | |
tolower() %>% | |
str_trim() %>% | |
str_replace_all('[\\s-]+', "-") %>% | |
str_remove_all('[^\\w-]+') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment