s <- "123-abc-123_abc-123_abc_123_abc"gsub("(_.*$)|\\d+", "\\1", s)
Standard input is empty
[1] "-abc-_abc-123_abc_123_abc"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!