I answer the question that was asked here about how to add the prefix "not_" to the word following the negation.
In the comments MrFlick suggested a solution using regex gsub("(?<=(?:\\bnot|n't) )(\\w+)\\b", "not_\\1", x, perl=T)
.
I would like to edit this regex to add the not_ prefix to all words following "not" or "not" until there is some kind of punctuation.
If I edit the cptn example, I would like to:
x <- "They didn't sell the company, and it went bankrupt"
To convert to:
"They didn't not_sell not_the not_company, and it went bankrupt"
Can using backreference still do the trick here? If so, then any example would be greatly appreciated. Thank!
source
share