rx_maybe: Optionally match an expression.

Description Usage Arguments References Examples

View source: R/rules.R

Description

This expression uses a quantifier ? to optionally match things. Specifically, the question mark makes the preceding token in the regular expression optional.

Usage

1
rx_maybe(.data = NULL, value)

Arguments

.data

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

value

Expression to optionally match

References

Quantifiers: https://www.regular-expressions.info/optional.html

Examples

1
2
3
4
5
6
7
8
9
rx_maybe(value = "abc")

# create expression
x <- rx() %>%
  rx_start_of_line() %>%
  rx_maybe("abc") %>%
  rx_end_of_line(enable = FALSE)

grepl(x, "xyz") # should be true

RVerbalExpressions documentation built on Nov. 6, 2019, 5:08 p.m.