I have a grep puzzle that\'s eluding me: I\'d like to remove the text following the final period in a collection of strings (i am using R, so perl
grep
perl
And a non-regex answer for no reason whatsoever:
test <- c("abc.com.foo.bar","ABCD.txt") sapply(strsplit(test,"\\."), function(x) paste0(head(x,-1),collapse=".") ) #[1] "abc.com.foo" "ABCD"