Say I need to strsplit caabacb
into individual letters except when a letter is followed by a b
, thus resulting in "c" "a" "ab" "a" "cb"
. I tried using the following line, which looks OK on regex tester but does not work in R. What did I do wrong?
strsplit('caabacb','(?!b)',perl=TRUE)
[[1]]
[1] "c" "a" "a" "b" "a" "c" "b"