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

6 lines
156 B
R
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
strip_comments <- function(str)
{
if(!require(stringr)) stop("you need to install the stringr package")
str_trim(str_split_fixed(str, "#|;", 2)[, 1])
}