str_snake_case: str_snake_case

Description Usage Arguments Examples

View source: R/str_snake_case.R

Description

Function used to convert character vectors to snake case format.

Usage

1
2
3
4
str_snake_case(
  string,
  whitespace = getOption("lettercase.whitespace", "[^\\w\\s-\\.]")
)

Arguments

string

object to turn into a title case

whitespace

regular expression pattern to match for white-space

  • 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

Examples

1
2
3
4
5
6
7
  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 " )
  

decisionpatterns/lettercase documentation built on May 23, 2020, 4:39 p.m.