string <- "0000A0000B0000C0000D0000E0000A0000"pattern <- c("XXXX")gsub("(^|[AB])0000", "\\1XXXX", string)
Standard input is empty
[1] "XXXXAXXXXBXXXXC0000D0000E0000AXXXX"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!