Description Usage Arguments Examples
Extract matching patterns from a string.
Replace matched patterns in a string.
1 2 3 4 5 6 7 | rr4r_extract(x, pattern, i = NULL)
rr4r_extract_all(x, pattern, i = NULL)
rr4r_extract_groups(x, pattern)
rr4r_replace(x, pattern, replacement)
|
x |
A character vector to look for the patterns in. |
pattern |
A pattern to look for. |
i |
Index of a capture group to extract. If not specified, extract the whole match. |
replacement |
A pattern to replace, or a function to generate the replacement strings. |
1 2 3 4 5 6 7 8 9 10 11 12 | ### These examples are taken from stringr's doc (?str_extract) ###
shopping_list <- c("apples x4", "bag of flour", "bag of sugar", "milk x2")
rr4r_extract(shopping_list, "\\d")
rr4r_extract(shopping_list, "[a-z]+")
rr4r_extract(shopping_list, "[a-z]{1,4}")
rr4r_extract(shopping_list, "\\b[a-z]{1,4}\\b")
# Extract all matches
rr4r_extract_all(shopping_list, "[a-z]+")
rr4r_extract_all(shopping_list, "\\b[a-z]+\\b")
rr4r_extract_all(shopping_list, "\\d")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.