library(stringr)dirty_string <- c('finance analyst i')str_replace(dirty_string, "\\s+\\w+$", "")
Standard input is empty
[1] "finance analyst"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!