rx_anything: Match any character(s) any (including zero) number of times.

Description Usage Arguments References Examples

View source: R/rules.R

Description

This expression will match everything except line breaks using the dot and the star. The Dot . is a metacharacter and the Star * is a quantifier. When combined the expression is considered greedy because it will match everything (except line breaks) 0 or more times.

Usage

1
rx_anything(.data = NULL, mode = "greedy")

Arguments

.data

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

mode

Matching mode (greedy (default) orlazy). Lazy matching stops after the first match, greedy continues searching until end of the string and then back-tracks to the last match.

References

Dot: https://www.regular-expressions.info/dot.html

Star Quantifier: https://www.regular-expressions.info/repeat.html

Greedy and Lazy Quantifiers: https://www.regular-expressions.info/repeat.html#greedy

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
rx_anything()
rx_anything(mode = "lazy")

x <- rx() %>%
  rx_start_of_line() %>%
  rx_anything() %>%
  rx_end_of_line()

grepl(x, "anything!")     # this should be true
grepl(rx_anything(), "")  # this should be true
grepl(rx_something(), "") # this should be false

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