string <- c("AB1C1", "AB2C2", "AB3C20")sub("(.*)(\\D\\d+)$", "\\1_\\2", string)## => [1] "AB1_C1" "AB2_C2" "AB3_C20"
Standard input is empty
[1] "AB1_C1" "AB2_C2" "AB3_C20"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!