Skip to contents

This function checks if a given string adheres to snake_case naming conventions. By default (strict = TRUE), it only allows lowercase letters separated by underscores. If strict is FALSE, uppercase letters are also permitted.

Usage

isSnakeCase(x, strict = TRUE)

Arguments

x

A character string to check.

strict

Logical indicating whether the string should strictly contain only lowercase letters (TRUE) or can include uppercase ones (FALSE). Default is TRUE.

Value

TRUE if the string is snake_case according to the specified strictness, FALSE otherwise.

Examples

isSnakeCase("snake_case")        # returns TRUE
#> [1] TRUE
isSnakeCase("Snake_Case")        # returns FALSE
#> [1] FALSE
isSnakeCase("snake_case", FALSE) # returns TRUE
#> [1] TRUE
isSnakeCase("Snake_Case", FALSE) # returns TRUE
#> [1] TRUE