Согласно этому коду кто-то может удалить html теги
#remove html tags
cleanFun <- function(htmlString) {
return(gsub("<.*?>", "", htmlString))
}
Как можно изменить его, чтобы сохранить только начало и конец тега
и удалить что-нибудь еще?
Пример ввода:
data.frame(id = c(1,2), text = c("<h1>keep </h1> also here <li> remove this tag </li> and <h1> this </h1>", "one more example <h2> false alarm </h2>"))
Ожидаемый результат:
data.frame(id = c(1,2), text = c("<h1>keep </h1> also here remove this tagand <h1> this </h1>", "one more example false alarm"))