s <- "abcde\n fghij<Foobar>"regmatches(s, regexec("(.*)<Foobar>", s))[[1]][2]
Standard input is empty
[1] "abcde\n fghij"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!