str_extract_all {stringr} | R Documentation |
Extract all pieces of a string that match a pattern.
str_extract_all(string, pattern)
string |
input character vector |
pattern |
pattern to look for. See regex for
description. |
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")