R/removeWhiteSpace.R

removeWhiteSpace <- function (str, leading = 1, trailing = 1) {

    if ((leading) && (trailing)) {
        ret <- gsub("^\\s+|\\s+$", "", str, perl = TRUE)
    }
    else if (leading) {
        ret <- gsub("^\\s+", "", str, perl = TRUE)
    }
    else if (trailing) {
        ret <- gsub("\\s+$", "", str, perl = TRUE)
    }
    else {
        ret <- str
    }
    ret

}

Try the ARTP2 package in your browser

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

ARTP2 documentation built on May 2, 2019, 3:38 p.m.