R/trimws.R

Defines functions trimws

trimws <- function(x) {
  whitespace <- "[ \t\r\n]"
  mysub <- function(re, x) sub(re, "", x, perl = TRUE)
  mysub(paste0(whitespace, "+$"), mysub(paste0("^", whitespace, "+"), x))
}
rossellhayes/ipa documentation built on July 18, 2020, 6:01 p.m.