trimws.Rd 714 Bytes
Newer Older
Radford Neal's avatar
Radford Neal committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
\name{trimws}
\alias{trimws}
\title{Remove Leading/Trailing Whitespace}
\description{
  Remove leading and/or trailing whitespace from character strings.
}
\usage{
trimws(x, which = c("both", "left", "right"))
}
\arguments{
  \item{x}{a character vector}
  \item{which}{a character string specifying whether to remove both
    leading and trailing whitespace (default), or only leading
    (\code{"left"}) or trailing (\code{"right"}).  Can be abbreviated.}
}
\details{
  For portability, \sQuote{whitespace} is taken as the character class
  \code{[ \\t\\r\\n]} (space, horizontal tab, line feed, carriage return).
}
\examples{
x <- "  Some text. "
x
trimws(x)
trimws(x, "l")
trimws(x, "r")
}
\keyword{character}