Last chance! 50% off unlimited learning
Sale ends in
str_snake_case(string, whitespace = getOption("lettercase.whitespace", "[^\w\s-\.]"))
* characters are all lower case
* non- \w
, \s
and - are dropped
* \w
and - are converted to underscore
* no support for acronyms
* multiple adjacent undescores are replaced by single underscore
* Underscores at beginning or end of names are dropped
str_snake_case( "One Flew Over The Cuckoo's Nest" )
str_snake_case( "Catch-22" ) # catch_22
str_snake_case( "Catch.22" )
str_snake_case( "Catch_22" )
str_snake_case( "Catch 22" )
str_snake_case( " Catch 22 " )
Run the code above in your browser using DataLab