R/ztrim.R

Defines functions trim

Documented in trim

##' @title Trim tring of (leading/trailing/all) white spaces
##' @param x String
##' @param all Trim all whitespaces? 
##' @param \dots additional arguments to lower level functions
##' @author Klaus K. Holst
##' @export
trim <- function(x,all=FALSE,...) {
    ## y <- gsub("^ .", "", x) # remove leading white space
    ## y <- gsub(". $", "", x) # remove trailing white space
    if (!all) return(gsub("^\\s+|\\s+$", "", x))
    return(gsub(" ","",x,fixed=TRUE))
}

Try the lava package in your browser

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

lava documentation built on May 2, 2019, 4:49 p.m.