v <- c(
stringr::str_c("A", c(1, 2, 9, 10, 11, 12, 99, 101, 102)),
stringr::str_c("B", c(1, 2, 9, 10, 21, 32, 99, 101, 102))
) %>% sample()
group_vector(v)
group_vector(v, pattern = "\\w\\d")
group_vector(v, pattern = "\\w(\\d)")
# unmatched part will alse be stored
group_vector(v, pattern = "\\d{2}")
Run the code above in your browser using DataLab