X <- c("L_1_3", "L_2_23", "L_3_91", "L_3_16")gsub("^L_\\d\\d?_(\\d+)$", "\\1", X)
Standard input is empty
[1] "3" "23" "91" "16"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!