v <- c("Arof_07122016_2.csv", "Another_99999_ccccc_2.csv")sub("^[^_]*_([^_]*).*", "\\1", v)
Standard input is empty
[1] "07122016" "99999"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!