Learn R Programming

RVerbalExpressions (version 0.0.0.9000)

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

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

anything(.data = NULL)

Arguments

.data

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

References

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

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

Examples

Run this code
# NOT RUN {
anything()

x <- start_of_line() %>%
  anything() %>%
  end_of_line()

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

# }

Run the code above in your browser using DataLab