regexPieces | R Documentation |
FIXME (eventually): when the stringi package regex code can handle
named subexpressions, use stri_extract_all_regex(...,
simplify=TRUE)
regexPieces(rx, s)
rx |
Perl-type regular expression with named fields, as
described in |
s |
character vector. |
a list of character vectors. Each vector corresponds to an
item of s
. The vector items are substrings of the input
item corresponding to named capture groups in rx
, in the
order they appear in the input item. The vector names are
those of the capture group. The same name might appear more
than once in the vector. If an item in the input does not
match any capture of rx
, then its corresponding vector
in the output is empty.
John Brzustowski jbrzusto@REMOVE_THIS_PART_fastmail.fm
rx = "(?<ayes>a+)|(?<bees>b+)|(?<sees>c+)"
s = c("anybbody", "something", "aebbfcbggaa")
regexPieces(rx, s)
## returns:
## [[1]]
## ayes bees
## "a" "bb"
##
## [[2]]
## named character(0)
##
## [[3]]
## ayes bees sees bees ayes
## "a" "bb" "c" "b" "aa"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.