R/str_split_one.R

Defines functions str_split_one

Documented in str_split_one

#' Title
#'
#' @param x
#' @param split
#'
#' @return
#' @export
#'
#' @examples
str_split_one <- function(string, pattern, n = Inf) {
  stopifnot(is.character(string), length(string) <= 1)
  if (length(string) == 1) {
    stringr::str_split(string = string, pattern = pattern, n = n)[[1]]
  } else {
    character()
  }
}
kphaterp/regexcitekphaterp documentation built on Jan. 17, 2022, 12:26 a.m.