Description Usage Arguments Details Value Author(s) Examples
Extract (sub)strings matching regex pattern.
1 | regextract(x, pattern, ...)
|
x |
a character vector. |
pattern |
regular expression to be found in |
... |
not used. |
Extract the substrings of x
that match the regex pattern pattern
.
The pattern may contain groups (enclosed in parentheses) which will result
in further substrings extracted.
Derived from the help on regmatches
, take a look at the help there
a character (string) matrix where the first column contains the global match for the pattern, each pair of '()' will result in another column with the respective match.
Benno Pütz puetz@psych.mpg.de
1 2 3 4 5 6 | s <- "Test: A1 BC23 DEF456"
pattern = "([[:alpha:]]+)([[:digit:]]+)"
regextract(s, pattern)
# equivalent to this example from the help page for grep()
lapply(regmatches(s, gregexpr(pattern, s)), function(e) regmatches(e, regexec(pattern, e)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.