View source: R/extract_groups.R
extract_groups | R Documentation |
This function takes a string input and applies the
str_match
function to extract the unique values
of the capture group requested by .tag_group
based on a regex
given by .capture_groups
.
extract_groups(.strings, .capture_groups = "(.+)_(.+)", .tag_group = 2)
.strings |
A character vector. Gives the strings to be extracted by
|
This function returns a character vector that is the result of
matching the input .strings
against the regex .capture_groups
,
selecting the desired capture group, .tag_groups
, and returning
the unique values of the result.
## Not run: char_vec <- c("extract", "a_b_c_d", "1_m.b-q_m") # accept 1 or more matches in each capture group extract_groups(char_vec, "(.+)_(.+)", 1) extract_groups(char_vec, "(.+)_(.+)", 2) # accept 0 or 1 matches in each capture group extract_groups(char_vec, "(.?)a(.?)", 1) extract_groups(char_vec, "(.?)a(.?)", 2) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.