str_extract | R Documentation |
Vectorised over string
, but not pattern
which must be
a single string (unlike stringr).
str_extract(string, pattern)
string |
|
pattern |
|
Returns a character vector
the same length as string
. Non-matching
elements will be replaced with NA
.
shopping_list <- c("apples x4", "bag of flour", "bag of sugar", "milk x2") str_extract(shopping_list, "\\d") str_extract(shopping_list, "[a-z]+") str_extract(shopping_list, "[a-z]{1,4}") str_extract(shopping_list, "\\b[a-z]{1,4}\\b")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.