str_extract_all {stringr} | R Documentation |
Vectorised over string
. pattern
should be
a single pattern, i.e. a character vector of length one.
str_extract_all(string, pattern)
string |
input vector. This must be an atomic vector, and will be coerced to a character vector |
pattern |
pattern to look for, as defined by a POSIX
regular expression. See the “Extended Regular
Expressions” section of |
list of character vectors.
str_extract
to extract the first match
shopping_list <- c("apples x4", "bag of flour", "bag of sugar", "milk x2") str_extract_all(shopping_list, "[a-z]+") str_extract_all(shopping_list, "\\b[a-z]+\\b") str_extract_all(shopping_list, "\\d")