string <- c("[1] cate 1", "[-1] cate -1", "[2] cate 2")stringr::str_extract(string, "(?<=\\[)-?\\d+(?=\\])")## => "1" "-1" "2"
Standard input is empty
[1] "1" "-1" "2"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!