fork download
  1. inputs <- c(
  2. "He's the bigest fan I know.",
  3. "I am a huge fan of his.",
  4. "I know she has lots of fans in his club",
  5. "I was cold and turned on the fan",
  6. "An air conditioner is better than 2 fans at cooling."
  7. )
  8. gsub(
  9. "((?:s?he(?: i|')s|(?:you|they|we)(?: a|')re|I(?: a|')m).{1,20})\\b(fan)(s?)\\b",
  10. '\\1\\2atic\\3',
  11. inputs,
  12. perl = TRUE, ignore.case = TRUE
  13. )
Success #stdin #stdout 0.18s 183680KB
stdin
Standard input is empty
stdout
[1] "He's the bigest fanatic I know."                     
[2] "I am a huge fanatic of his."                         
[3] "I know she has lots of fans in his club"             
[4] "I was cold and turned on the fan"                    
[5] "An air conditioner is better than 2 fans at cooling."