x <- c("NE-390-SM-04", "90055-SL-01-J", "NE-1478-SL-02", "87007-QM-01-J", "NE-9315-BM-01-A", "3121-SP-01", "1639-YL-01", "NE-9922-WM-01-J", "ND-2498-YL-01", "C-4008-PP-03-J", "876-C-4008-PP-03-J-234")sub("^.*?([0-9]+-[a-zA-Z]{2,}-[0-9]+).*", "\\1", x)
Standard input is empty
[1] "390-SM-04" "90055-SL-01" "1478-SL-02" "87007-QM-01" "9315-BM-01" [6] "3121-SP-01" "1639-YL-01" "9922-WM-01" "2498-YL-01" "4008-PP-03" [11] "4008-PP-03"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!