Learn R Programming

RVerbalExpressions (version 0.0.0.9000)

rx_or: Alternatively, match another expression.

Description

Expression to match instead. If both expressions exists, both will be returned. Note that this expression requires a verbal expression for the value parameter, see the example below. This may change in the future as I'd like to avoid nesting a function call in or().

Usage

rx_or(.data, value)

Arguments

.data

Expression to append, typically pulled from the pipe %>%

value

A verbal expression

Examples

Run this code
# NOT RUN {
# create an expression
x <- rx_find(value = "foo") %>%
  rx_or(rx_find(value = "bar"))

# create strings
string1 <- "foo!"
string2 <- "bar!"

# extract matches
regmatches(string1, gregexpr(x, string1))[[1]]
regmatches(string2, gregexpr(x, string2))[[1]]

# }

Run the code above in your browser using DataLab