Given this vector:
ba <- c('baa','aba','abba','abbba','aaba','aabba')'
I want to change the final a
of each word to i
except baa
and aba
.
I wrote the following line ...
gsub('(?<=a[ab]b{1,2})a','i',ba,perl=T)
but was told: PCRE pattern compilation error 'lookbehind assertion is not fixed length' at ')a'.
I looked around a little bit and apparently R/Perl can only lookahead for a variable width, not lookbehind. Any workaround to this problem? Thanks!
\\K
in the other direction, i.e. resetting the end point of the reported match? – Bevus