x <- c('SEF001DT45','BV004MF')results <- regmatches(x, regexpr('[A-Z]{2}.*?\\K[A-Z]{2}', x, perl=TRUE))results
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!