x <- c('SEF001DT45','BV004MF')library(stringr)results <- stringr::str_match(x, '[A-Z]{2}.*?([A-Z]{2})')results[,2]
Standard input is empty
[1] "DT" "MF"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!