x <- c("foo bar", "foo")grep("(?s)foo(?!.*bar)", x, perl=TRUE, value=TRUE)
Standard input is empty
[1] "foo"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!