fork download
  1. df<-structure(list(name = structure(c(1L, 3L, 2L), .Label = c("James",
  2. "Jim", "John"), class = "factor"), age = c(34L, 30L, 27L), message = structure(1:3, .Label = c("hello, my name is James. ",
  3. "hello, my name is John. Here is my favourite website https://stackoverflow.com",
  4. "Hi! I'm another persoon whose name begins with a J! Here is something that should be filtered out: <filter>"
  5. ), class = "factor")), .Names = c("name", "age", "message"), class = "data.frame", row.names = c(NA,
  6. -3L))
  7. df$message <- gsub("(?:\\s+|^)\\S*(?<!\\w)(?:https?|<filter>)(?!\\w)\\S*", "", df$message, perl=TRUE)
  8. df$message
Success #stdin #stdout 0.16s 175424KB
stdin
Standard input is empty
stdout
[1] "hello, my name is James. "                                                                         
[2] "hello, my name is John. Here is my favourite website"                                              
[3] "Hi! I'm another persoon whose name begins with a J! Here is something that should be filtered out:"