R/trim_ws.R

Defines functions trim_ws

Documented in trim_ws

#' trim_ws
#'
#' Returns character vector without extra spaces and trimmed of white space.
#'
#' @param x Character vector
#' @return Character vector without extra spaces
#' @export
trim_ws <- function(x) {
  x <- gsub("[ ]{2,}", " ", x)
  gsub("^[ ]+|[ ]+$", "", x)
}

Try the tfse package in your browser

Any scripts or data that you put into this service are public.

tfse documentation built on May 2, 2019, 11:28 a.m.