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 April 6, 2023, 1:10 a.m.