R/trimSpace.R

Defines functions trimSpace

Documented in trimSpace

trimSpace <- function(x, leading = TRUE, trailing = TRUE, space = "[:space:]"){
    if(leading){
        pattern <- paste("^[", space, "]*", sep = "", collapse = "")
        x <- sub(pattern = pattern, replacement =  "", x = x)
    }
    if(trailing){
        pattern <- paste("[", space, "]*$", sep = "", collapse = "")
        x <- sub(pattern = pattern, replacement =  "", x = x)
    }
    return(x)
}

Try the seqinr package in your browser

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

seqinr documentation built on May 29, 2024, 6:36 a.m.