I have a list of strings which contain random characters such as:
list=list() list[1] = \"djud7+dg[a]hs667\" list[2] = \"7fd*hac11(5)\" list[3] = \"2tu,g7gka
A stringr solution with str_match_all and piped operators. For the first solution:
stringr
str_match_all
library(stringr) str_match_all(ll, "[0-9]+") %>% unlist %>% unique %>% as.numeric
Second solution:
str_match_all(ll, "[0-9]") %>% unlist %>% unique %>% as.numeric
(Note: I've also called the list ll)
ll