fork download
  1. Data <- c("Posted by ondrej on 29 Feb 2020."
  2. , "Posted by ona'je on 29feb 2020")
  3.  
  4. sub(" +?on.*$", "", Data) # "Posted by ondrej" "Posted by ona'je"
  5. sub(" +?on.*", "", Data) # "Posted bydrej on 29 Feb 2020." "Posted bya'je on 29feb 2020"
  6. sub(" +?on(.*)", "", Data) # as expected
  7. sub(" +on.*", "", Data) # as expected
  8.  
  9.  
Success #stdin #stdout 0.22s 39208KB
stdin
Standard input is empty
stdout
[1] "Posted by ondrej" "Posted by ona'je"
[1] "Posted bydrej on 29 Feb 2020." "Posted bya'je on 29feb 2020"  
[1] "Posted by" "Posted by"
[1] "Posted by" "Posted by"