Nothing
#' Split a string based on CamelCase.
#'
#' Vectorized over `string`.
#'
#' @inheritParams str_after_nth
#' @param lower Do you want the output to be all lower case (or as is)?
#'
#' @return A list of character vectors, one list element for each element of
#' `string`.
#'
#' @references Adapted from Ramnath Vaidyanathan's answer at
#' http://stackoverflow.com/questions/8406974/splitting-camelcase-in-r.
#'
#' @examples
#' str_split_camel_case(c("RoryNolan", "NaomiFlagg", "DepartmentOfSillyHats"))
#' str_split_camel_case(c("RoryNolan", "NaomiFlagg", "DepartmentOfSillyHats",
#' lower = TRUE
#' ))
#' @family splitters
#' @export
str_split_camel_case <- function(string, lower = FALSE) {
if (is_l0_char(string)) {
return(list())
}
checkmate::assert_character(string)
checkmate::assert_flag(lower)
string <- gsub("^[^[:alnum:]]+|[^[:alnum:]]+$", "", string) %>%
gsub("(?!^)(?=[[:upper:]])", " ", ., perl = TRUE)
if (lower) string <- str_to_lower(string)
str_split(string, " ")
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.