fork download
  1. sentences <- "The ground was rocky with no cracks in it\r\nNo diggedy, no doubt\r\nUnderstandably, there is no way an elephant can be green"
  2. rx <- "(?mxi)^ # Start of a line
  3. (?: # Outer container group start
  4. (?!.*\\b(?:with|there\\h(?:is|are))\\h+no\\b) # no 'with/there is/are no' before 'no'
  5. .*\\bno\\b # 'no' whole word after 0+ chars
  6. (?![?:]) # cannot be followed with ? or :
  7. | # or
  8. .* # any 0+ chars
  9. [?:]\\h*n(?![a-z]) # ? or : followed with 0+ spaces, 'n' not followed with any letter
  10. ) # container group end
  11. .* # the rest of the line and 0+ line breaks
  12. \\R*"
  13. res <- gsub(rx, "", sentences, perl=TRUE)
  14. cat(res, sep="\n")
Success #stdin #stdout 0.16s 175424KB
stdin
Standard input is empty
stdout
The ground was rocky with no cracks in it
Understandably, there is no way an elephant can be green