fork(1) download
  1. test <- c("i really wasn aware and i wasnt aware at all. but i wasn't aware. just wasn't. this wasn45'e meant to be. it wasn@'re simple",
  2. "Wasn&^$tt that nice?",
  3. "You say wasnmmmt?",
  4. "No, he wasn&#t#@$.",
  5. "She wasn%#@t##, I know.")
  6. gsub("\\b(wasn)\\S*\\b(?:\\S*(\\p{P}))?", "\\1't\\2", test, ignore.case=TRUE, perl=TRUE)
Success #stdin #stdout 0.26s 39408KB
stdin
Standard input is empty
stdout
[1] "i really wasn't aware and i wasn't aware at all. but i wasn't aware. just wasn't. this wasn't meant to be. it wasn't simple"
[2] "Wasn't that nice?"                                                                                                          
[3] "You say wasn't?"                                                                                                            
[4] "No, he wasn't."                                                                                                             
[5] "She wasn't, I know."