I need to get the words before and after a unique character (in my case: &) in a string in R.
I need to get "word1" from something like this: "... something is something word1 and word2 is something ..."
I can get the word after using the Perl regular expression in R: (?<=& )[^ ]*(?= )
(It seems to behave the way I would like. I got this from combing the answers I found on this site)
I need to get the word preceding the character &. Changes the length of words and the number of other preceding words, as well as spaces. A word can be letters and numbers, simply connected by spaces on both sides.
source
share