| Version: | 0.11.1 | 
| Date: | 2023-08-27 | 
| Title: | Convert Strings into any Case | 
| Description: | A consistent, flexible and easy to use tool to parse and convert strings into cases like snake or camel among others. | 
| Maintainer: | Malte Grosser <malte.grosser@gmail.com> | 
| Depends: | R (≥ 3.2) | 
| Imports: | stringr, stringi | 
| Suggests: | testthat, covr, tibble, purrrlyr, knitr, rmarkdown, magrittr | 
| URL: | https://github.com/Tazinho/snakecase | 
| BugReports: | https://github.com/Tazinho/snakecase/issues | 
| Encoding: | UTF-8 | 
| License: | GPL-3 | 
| RoxygenNote: | 6.1.1 | 
| VignetteBuilder: | knitr | 
| NeedsCompilation: | no | 
| Packaged: | 2023-08-27 20:30:20 UTC; malte | 
| Author: | Malte Grosser [aut, cre] | 
| Repository: | CRAN | 
| Date/Publication: | 2023-08-27 22:50:09 UTC | 
Internal abbreviation marker, marks abbreviations with an underscore behind.
Useful if parsing_option 1 is needed, but some abbreviations need parsing_option 2.
Description
Internal abbreviation marker, marks abbreviations with an underscore behind.
Useful if parsing_option 1 is needed, but some abbreviations need parsing_option 2.
Usage
abbreviation_internal(string, abbreviations = NULL)
Arguments
| string | A string (for example names of a data frame). | 
| abbreviations | character with (uppercase) abbreviations. This marks
abbreviations with an underscore behind (in front of the parsing).
Useful if  | 
Value
A character vector.
Author(s)
Malte Grosser, malte.grosser@gmail.com
Specific case converter shortcuts
Description
Wrappers around to_any_case()
Usage
to_snake_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
  parsing_option = 1, transliterations = NULL, numerals = "middle",
  sep_out = NULL, unique_sep = NULL, empty_fill = NULL,
  prefix = "", postfix = "")
to_lower_camel_case(string, abbreviations = NULL,
  sep_in = "[^[:alnum:]]", parsing_option = 1,
  transliterations = NULL, numerals = "middle", sep_out = NULL,
  unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")
to_upper_camel_case(string, abbreviations = NULL,
  sep_in = "[^[:alnum:]]", parsing_option = 1,
  transliterations = NULL, numerals = "middle", sep_out = NULL,
  unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")
to_screaming_snake_case(string, abbreviations = NULL,
  sep_in = "[^[:alnum:]]", parsing_option = 1,
  transliterations = NULL, numerals = "middle", sep_out = NULL,
  unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")
to_parsed_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
  parsing_option = 1, transliterations = NULL, numerals = "middle",
  sep_out = NULL, unique_sep = NULL, empty_fill = NULL,
  prefix = "", postfix = "")
to_mixed_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
  parsing_option = 1, transliterations = NULL, numerals = "middle",
  sep_out = NULL, unique_sep = NULL, empty_fill = NULL,
  prefix = "", postfix = "")
to_lower_upper_case(string, abbreviations = NULL,
  sep_in = "[^[:alnum:]]", parsing_option = 1,
  transliterations = NULL, numerals = "middle", sep_out = NULL,
  unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")
to_upper_lower_case(string, abbreviations = NULL,
  sep_in = "[^[:alnum:]]", parsing_option = 1,
  transliterations = NULL, numerals = "middle", sep_out = NULL,
  unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")
to_swap_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
  parsing_option = 1, transliterations = NULL, numerals = "middle",
  sep_out = NULL, unique_sep = NULL, empty_fill = NULL,
  prefix = "", postfix = "")
to_sentence_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
  parsing_option = 1, transliterations = NULL, numerals = "middle",
  sep_out = NULL, unique_sep = NULL, empty_fill = NULL,
  prefix = "", postfix = "")
to_random_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
  parsing_option = 1, transliterations = NULL, numerals = "middle",
  sep_out = NULL, unique_sep = NULL, empty_fill = NULL,
  prefix = "", postfix = "")
to_title_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
  parsing_option = 1, transliterations = NULL, numerals = "middle",
  sep_out = NULL, unique_sep = NULL, empty_fill = NULL,
  prefix = "", postfix = "")
Arguments
| string | A string (for example names of a data frame). | 
| abbreviations | character. (Case insensitive) matched abbreviations are surrounded by underscores. In this way, they can get recognized by the parser. This is useful when e.g.  Use this feature with care: One letter abbreviations and abbreviations next to each other are hard to read and also not easy to parse for further processing. | 
| sep_in | (short for separator input) if character, is interpreted as a
regular expression (wrapped internally into  | 
| parsing_option | An integer that will determine the parsing_option. 
 | 
| transliterations | A character vector (if not  | 
| numerals | A character specifying the alignment of numerals ( | 
| sep_out | (short for separator output) String that will be used as separator. The defaults are  | 
| unique_sep | A string. If not  | 
| empty_fill | A string. If it is supplied, then each entry that matches "" will be replaced by the supplied string to this argument. | 
| prefix | prefix (string). | 
| postfix | postfix (string). | 
Value
A character vector according the specified parameters above.
A character vector according the specified target case.
Note
caseconverters are vectorised over string, sep_in, sep_out,
empty_fill, prefix and postfix.
Author(s)
Malte Grosser, malte.grosser@gmail.com
Malte Grosser, malte.grosser@gmail.com
See Also
snakecase on github, to_any_case for flexible high level conversion and more examples.
Examples
strings <- c("this Is a Strange_string", "AND THIS ANOTHER_One", NA)
to_snake_case(strings)
to_lower_camel_case(strings)
to_upper_camel_case(strings)
to_screaming_snake_case(strings)
to_lower_upper_case(strings)
to_upper_lower_case(strings)
to_parsed_case(strings)
to_mixed_case(strings)
to_swap_case(strings)
to_sentence_case(strings)
to_random_case(strings)
to_title_case(strings)
Internal helper to test the design rules for any string and setting of to_any_case()
Description
Internal helper to test the design rules for any string and setting of to_any_case()
Usage
check_design_rule(string, sep_in = NULL, transliterations = NULL,
  sep_out = NULL, prefix = "", postfix = "", unique_sep = NULL,
  empty_fill = NULL, parsing_option = 1)
Arguments
| string | A string (for example names of a data frame). | 
| sep_in | String that will be wrapped internally into  | 
| transliterations | A character vector (if not  | 
| sep_out | String that will be used as separator. The defaults are  | 
| prefix | prefix (string). | 
| postfix | postfix (string). | 
| unique_sep | A string. If it is supplied, then duplicated names will get a suffix integer in the order of their appearance. The suffix is separated by the supplied string to this argument. | 
| empty_fill | A string. If it is supplied, then each entry that matches "" will be replaced by the supplied string to this argument. | 
| parsing_option | An integer that will determine the parsing_option. 
 | 
Value
A character vector separated by underscores, containing the parsed string.
Author(s)
Malte Grosser, malte.grosser@gmail.com
Parsing helpers
Description
Mainly for usage within to_parsed_case_internal
Usage
parse1_pat_cap_smalls(string)
parse2_pat_digits(string)
parse3_pat_caps(string)
parse4_pat_cap(string)
parse5_pat_non_alnums(string)
parse6_mark_digits(string)
parse7_pat_caps_smalls(string)
parse8_pat_smalls_after_non_alnums(string)
Arguments
| string | A string. | 
Value
A partly parsed character vector.
Author(s)
Malte Grosser, malte.grosser@gmail.com
Internal function that replaces regex matches with underscores
Description
Internal function that replaces regex matches with underscores
Usage
preprocess_internal(string, sep_in)
Arguments
| string | A string. | 
| sep_in | (short for separator input) A regex supplied as a character (if not  | 
Value
A character containing the parsed string.
Author(s)
Malte Grosser, malte.grosser@gmail.com
Internal helper for "lower_upper", "upper_lower". This helper returns a logical vector with TRUE for the first and every second string of those which contain an alphabetic character
Description
Internal helper for "lower_upper", "upper_lower". This helper returns a logical vector with TRUE for the first and every second string of those which contain an alphabetic character
Usage
relevant(string)
Arguments
| string | A string (for example names of a data frame). | 
Value
A logical vector.
Author(s)
Malte Grosser, malte.grosser@gmail.com
Internal helper to replace special characters.
Description
Internal helper to replace special characters.
Usage
replace_special_characters_internal(string, transliterations, case)
Arguments
| string | A string (for example names of a data frame). | 
| transliterations | A character vector (if not  | 
| case | Length one character, from the input options of  | 
Value
A character vector.
Author(s)
Malte Grosser, malte.grosser@gmail.com
General case conversion
Description
Function to convert strings to any case
Usage
to_any_case(string, case = c("snake", "small_camel", "big_camel",
  "screaming_snake", "parsed", "mixed", "lower_upper", "upper_lower",
  "swap", "all_caps", "lower_camel", "upper_camel", "internal_parsing",
  "none", "flip", "sentence", "random", "title"), abbreviations = NULL,
  sep_in = "[^[:alnum:]]", parsing_option = 1,
  transliterations = NULL, numerals = c("middle", "left", "right",
  "asis", "tight"), sep_out = NULL, unique_sep = NULL,
  empty_fill = NULL, prefix = "", postfix = "")
Arguments
| string | A string (for example names of a data frame). | 
| case | The desired target case, provided as one of the following: 
 There are five "special" cases available: 
 | 
| abbreviations | character. (Case insensitive) matched abbreviations are surrounded by underscores. In this way, they can get recognized by the parser. This is useful when e.g.  Use this feature with care: One letter abbreviations and abbreviations next to each other are hard to read and also not easy to parse for further processing. | 
| sep_in | (short for separator input) if character, is interpreted as a
regular expression (wrapped internally into  | 
| parsing_option | An integer that will determine the parsing_option. 
 | 
| transliterations | A character vector (if not  | 
| numerals | A character specifying the alignment of numerals ( | 
| sep_out | (short for separator output) String that will be used as separator. The defaults are  | 
| unique_sep | A string. If not  | 
| empty_fill | A string. If it is supplied, then each entry that matches "" will be replaced by the supplied string to this argument. | 
| prefix | prefix (string). | 
| postfix | postfix (string). | 
Value
A character vector according the specified parameters above.
Note
to_any_case() is vectorised over string, sep_in, sep_out,
empty_fill, prefix and postfix.
Author(s)
Malte Grosser, malte.grosser@gmail.com
See Also
snakecase on github or 
caseconverter for some handy shortcuts.
Examples
### abbreviations
to_snake_case(c("HHcity", "newUSElections"), abbreviations = c("HH", "US"))
to_upper_camel_case("succesfullGMBH", abbreviations = "GmbH")
to_title_case("succesfullGMBH", abbreviations = "GmbH")
### sep_in (input separator)
string <- "R.St\u00FCdio: v.1.0.143"
to_any_case(string)
to_any_case(string, sep_in = ":|\\.")
to_any_case(string, sep_in = ":|(?<!\\d)\\.")
            
### parsing_option
# the default option makes no sense in this setting
to_parsed_case("HAMBURGcity", parsing_option = 1)
# so the second parsing option is the way to address this example
to_parsed_case("HAMBURGcity", parsing_option = 2)
# By default (option 1) characters are converted after non alpha numeric characters.
# To suppress this behaviour add a minus to the parsing_option
to_upper_camel_case("lookBehindThe.dot", parsing_option = -1)
# For some exotic cases parsing option 3 might be of interest
to_parsed_case("PARSingOption3", parsing_option = 3)
# There may be reasons to suppress the parsing
to_any_case("HAMBURGcity", parsing_option = 0)
### transliterations
to_any_case("\u00E4ngstlicher Has\u00EA", transliterations = c("german", "Latin-ASCII"))
### case
strings <- c("this Is a Strange_string", "AND THIS ANOTHER_One")
to_any_case(strings, case = "snake")
to_any_case(strings, case = "lower_camel") # same as "small_camel"
to_any_case(strings, case = "upper_camel") # same as "big_camel"
to_any_case(strings, case = "all_caps") # same as "screaming_snake"
to_any_case(strings, case = "lower_upper")
to_any_case(strings, case = "upper_lower")
to_any_case(strings, case = "sentence")
to_any_case(strings, case = "title")
to_any_case(strings, case = "parsed")
to_any_case(strings, case = "mixed")
to_any_case(strings, case = "swap")
to_any_case(strings, case = "random")
to_any_case(strings, case = "none")
to_any_case(strings, case = "internal_parsing")
### numerals
to_snake_case("species42value 23month 7-8", numerals = "asis")
to_snake_case("species42value 23month 7-8", numerals = "left")
to_snake_case("species42value 23month 7-8", numerals = "right")
to_snake_case("species42value 23month 7-8", numerals = "middle")
to_snake_case("species42value 23month 7-8", numerals = "tight")
### sep_out (output separator)
string <- c("lowerCamelCase", "ALL_CAPS", "I-DontKNOWWhat_thisCASE_is")
to_snake_case(string, sep_out = ".")
to_mixed_case(string, sep_out = " ")
to_screaming_snake_case(string, sep_out = "=")
### empty_fill
to_any_case(c("","",""), empty_fill = c("empty", "empty", "also empty"))
### unique_sep
to_any_case(c("same", "same", "same", "other"), unique_sep = c(">"))
### prefix and postfix
to_upper_camel_case("some_path", sep_out = "//", 
  prefix = "USER://", postfix = ".exe")
Internal parser, which is relevant for preprocessing, parsing and parsing options
Description
Internal parser, which is relevant for preprocessing, parsing and parsing options
Usage
to_parsed_case_internal(string, parsing_option = 1L, numerals,
  abbreviations, sep_in)
Arguments
| string | A string. | 
| parsing_option | An integer that will determine the parsing option. 
 | 
| numerals | A character specifying the alignment of numerals ( | 
| abbreviations | A character string specifying abbreviations that should be marked to be recognized by later parsing. | 
| sep_in | A character (regular expression) used to specify input separators. | 
Value
A character vector separated by underscores, containing the parsed string.
Author(s)
Malte Grosser, malte.grosser@gmail.com