sub('^(.*)_.*', '\\1', "surname_name_job")
Standard input is empty
[1] "surname_name"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!