str_extract_all | R Documentation |
Vectorised over string
, but not pattern
which must be
a single string (unlike stringr).
str_extract_all(string, pattern, simplify = FALSE)
string |
|
pattern |
|
simplify |
|
Returns a list
the same length as string
, unless simply = TRUE
wherein a character matrix
is returned with non-matching elements
replaced with ""
.
shopping_list <- c("apples x4", "bag of flour", "bag of sugar", "milk x2") # Extract all matches str_extract_all(shopping_list, "[a-z]+") str_extract_all(shopping_list, "\\b[a-z]+\\b") str_extract_all(shopping_list, "\\d") # Simplify results into character matrix str_extract_all(shopping_list, "\\b[a-z]+\\b", simplify = TRUE) str_extract_all(shopping_list, "\\d", simplify = TRUE) # Extract all words str_extract_all("This is, suprisingly, a sentence.", "\\w+")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.