sub('(?(?=.*bd)bd|bc)', 'zz', c('abcabe','abcabd'), perl=TRUE)
Standard input is empty
[1] "azzabe" "abcazz"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!