fork download
  1. tests = c(
  2. "dog cat",
  3. "dogs and cats",
  4. "dog and cat",
  5. "dog and fluffy cats",
  6. "cats and dogs",
  7. "cat and dog",
  8. "fluffy cats and fluffy dogs")
  9. neg_pattern = "^(?!.*dog.*cat).*cat"
  10. grep(neg_pattern, tests, perl = TRUE, value = TRUE)
Success #stdin #stdout 0.29s 175424KB
stdin
Standard input is empty
stdout
[1] "cats and dogs"               "cat and dog"                
[3] "fluffy cats and fluffy dogs"