RosettaCodeData/Task/Strip-comments-from-a-string/R/strip-comments-from-a-strin...

6 lines
156 B
R

strip_comments <- function(str)
{
if(!require(stringr)) stop("you need to install the stringr package")
str_trim(str_split_fixed(str, "#|;", 2)[, 1])
}