library(stringr)str = c("2019/01/01/07/556662_cba3a4fc-cb8f-4150-859f-5f21a38373d0")str_match(str, "/([^_/]+)_[^/\\s]*")[,2] # [1] "556662"
Standard input is empty
[1] "556662"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!