Description Usage Arguments Value Note References See Also Examples
Match one string or another.
1 2 3 4 5 |
... |
Character vectors. |
capture |
A logical value indicating whether or not the result should be captured. See note. |
x |
A character vector. |
y |
A character vector. |
A character vector representing part or all of a regular expression.
or
takes multiple character vector inputs and returns a
character vector of the inputs separated by pipes. %|%
is an operator
interface to this function. or1
takes a single character vector and
returns a string collapsed by pipes.
When capture
is TRUE
, the values are wrapped in a capture
group (see capture
). When capture
is FALSE
(the
default for or
and or1
), the values are wrapped in a
non-capture group (see token
). When capture
is
NA
, (the case for %|%
) the values are not wrapped in
anything.
http://www.regular-expressions.info/alternation.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # or takes an arbitrary number of arguments and groups them without capture
# Notice the recycling of inputs
or(letters, month.abb, "foo")
# or1 takes a single character vector
or1(c(letters, month.abb, "foo")) # Not the same as before!
# Capture the group
or1(letters, capture = TRUE)
# Don't create a group
or1(letters, capture = NA)
# The pipe operator doesn't group
letters %|% month.abb %|% "foo"
# Usage
(rx <- or("dog", "cat", "hippopotamus"))
stringi::stri_detect_regex(c("boondoggle", "caterwaul", "water-horse"), rx)
|
<regex> (?:a|Jan|foo)
<regex> (?:b|Feb|foo)
<regex> (?:c|Mar|foo)
<regex> (?:d|Apr|foo)
<regex> (?:e|May|foo)
<regex> (?:f|Jun|foo)
<regex> (?:g|Jul|foo)
<regex> (?:h|Aug|foo)
<regex> (?:i|Sep|foo)
<regex> (?:j|Oct|foo)
<regex> (?:k|Nov|foo)
<regex> (?:l|Dec|foo)
<regex> (?:m|Jan|foo)
<regex> (?:n|Feb|foo)
<regex> (?:o|Mar|foo)
<regex> (?:p|Apr|foo)
<regex> (?:q|May|foo)
<regex> (?:r|Jun|foo)
<regex> (?:s|Jul|foo)
<regex> (?:t|Aug|foo)
<regex> (?:u|Sep|foo)
<regex> (?:v|Oct|foo)
<regex> (?:w|Nov|foo)
<regex> (?:x|Dec|foo)
<regex> (?:y|Jan|foo)
<regex> (?:z|Feb|foo)
<regex> (?:a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|foo)
<regex> (a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z)
<regex> a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z
<regex> a|Jan|foo
<regex> b|Feb|foo
<regex> c|Mar|foo
<regex> d|Apr|foo
<regex> e|May|foo
<regex> f|Jun|foo
<regex> g|Jul|foo
<regex> h|Aug|foo
<regex> i|Sep|foo
<regex> j|Oct|foo
<regex> k|Nov|foo
<regex> l|Dec|foo
<regex> m|Jan|foo
<regex> n|Feb|foo
<regex> o|Mar|foo
<regex> p|Apr|foo
<regex> q|May|foo
<regex> r|Jun|foo
<regex> s|Jul|foo
<regex> t|Aug|foo
<regex> u|Sep|foo
<regex> v|Oct|foo
<regex> w|Nov|foo
<regex> x|Dec|foo
<regex> y|Jan|foo
<regex> z|Feb|foo
<regex> (?:dog|cat|hippopotamus)
[1] TRUE TRUE FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.