R/cap_first.R

Defines functions cap_first

Documented in cap_first

#' Capitalise the first letter of all words
#'
#' @param string String or character vector to pass through.
#'
#' @examples
#' cap_first("steeles pots and pans")
#'
#' @export
cap_first <- function(string) {
  gsub("(^|[[:space:]])([[:alpha:]])", "\\1\\U\\2", string, perl = TRUE)
}
martinctc/textworks documentation built on Oct. 5, 2022, 8:09 p.m.