fork download
  1. string <- c("[1] cate 1", "[-1] cate -1", "[2] cate 2")
  2. stringr::str_extract(string, "(?<=\\[)-?\\d+(?=\\])")
  3. ## => "1" "-1" "2"
  4.  
Success #stdin #stdout 0.38s 41596KB
stdin
Standard input is empty
stdout
[1] "1"  "-1" "2"