library(stringr)Times <- c("12h00","16h30","Afternoon","15h00","14h20","7h30","06h00")str_extract(Times, '[1-9]\\d*(?=h)')
Standard input is empty
[1] "12" "16" NA "15" "14" "7" "6"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!