Learn R Programming

FastUtils (version 0.2.1)

isSnakeCase: Check if String is snake_case

Description

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)

Value

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

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.

Examples

Run this code
isSnakeCase("snake_case")        # returns TRUE
isSnakeCase("Snake_Case")        # returns FALSE
isSnakeCase("snake_case", FALSE) # returns TRUE
isSnakeCase("Snake_Case", FALSE) # returns TRUE

Run the code above in your browser using DataLab