Learn R Programming

FastUtils (version 0.2.1)

trySplitWords: Try to Split Words Based on Naming Convention

Description

This function attempts to split characters into its component words (and by default, all in lowercase) based on camelCase, PascalCase, or snake_case conventions. If the string doesn't match any of these conventions, it returns all groups of letters.

Usage

trySplitWords(..., conseq = TRUE, strictSnake = FALSE, uncase = TRUE)

Value

A list of character vectors, each containing the parts of the string split into individual words.

Arguments

...

character(s) to be split, treated as a single vector after unlisting.

conseq

A logical indicating whether the conseq argument in splitCamel()/splitPascal() should be TRUE or FALSE.

strictSnake

A logical indicating the strict argument in isSnakeCase().

uncase

A logical indicating whether to remove all casing in the output to lowercase.

See Also

splitCamel, splitPascal, splitSnake, isCamelCase, isPascalCase, isSnakeCase

Examples

Run this code
trySplitWords("camelCaseExample")
trySplitWords("PascalCaseExample")
trySplitWords(
    "snake_case_example", c("more_snake_cases"), "third_snake_case"
)
trySplitWords("some|random|case")
trySplitWords("Space Words", "UPPER_CASE", uncase = TRUE)

Run the code above in your browser using DataLab