fork download
  1. x <- c("PIA+1+TC_5504_00_312010_0050+50103 AB346 type 5334",
  2. "PIA+1+TC_3444_00_312010_0133+0140",
  3. "PIA+1+DRW/50488665600/01/000:DW",
  4. "PIA+1+TC_5635_00_312019_2644+LoremIpsum",
  5. "PIA+1+TC_5635_00_312010_0040+63503 AB346 type 5334",
  6. "PIA+1+TC_5635_00_312018_0223+DolorSit",
  7. "PIA+1+TC_5635_00_312019_2644+DolorSit")
  8. res <- sub("^PIA\\+\\d\\+(?!.*(?:LoremIpsum|DolorSit))(.*)|.*", "\\1", x, perl=TRUE)
  9. res[res != ""]
Success #stdin #stdout 0.21s 39456KB
stdin
Standard input is empty
stdout
[1] "TC_5504_00_312010_0050+50103 AB346 type 5334"
[2] "TC_3444_00_312010_0133+0140"                 
[3] "DRW/50488665600/01/000:DW"                   
[4] "TC_5635_00_312010_0040+63503 AB346 type 5334"