Description Usage Arguments Value See Also
This is a convenience function to capture substrings from textual data.
Uses str_match_all
internally but instead of returning everything, always returns only one single part of the match, depending on parameters capture_n
and capture_group
.
1 2 3 4 5 6 7 | extract_substring(
string,
pattern,
capture_n = 1,
capture_bracket = 0,
missing = NA_character_
)
|
string |
string to extract |
pattern |
regular expression pattern to search for |
capture_n |
within each string, which match of the |
capture_bracket |
for the captured match, which capture group should be extracted? i.e. which parentheses-enclosed segment of the |
missing |
what to replace missing values with? Note that values can be missing because there are not enough captured matches or because the actual capture_bracket is empty. |
character vector of same length as string
with the extracted substrings
Other data extraction functions:
extract_data
,
extract_word()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.