regexConstruction | R Documentation |
humdrumR
includes some helpful functions for creating new regular expressions which work with the
stringr package.
captureRE(strs, n = "")
captureUniq(strs, zero = TRUE)
orRE(...)
captureRE
will take a character vector and collapse it to a "capture group."
The n
argument can be used to append a number tag, for instance '*'
(zero or more) to the group.
I.e., captureRE(c("a", "b", "c"), '*')
will output "[abc]*"
.
captureUniq
will make a similar capture group to captureRE
, but with an expression
that makes sure that only 1 or more of the same character repeats.
For instance, captureUniq(c('a', 'b','c'))
will return "([abc])\\1*"
—this expression will match
"aaa"
or "bb"
but not "aabb"
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.