Learn R Programming

RVerbalExpressions (version 0.0.0.9000)

rx_count: Match the previous stuff exact number of times.

Description

This function simply adds a {n} to the end of the expression.

Usage

rx_count(.data = NULL, n = 1)

Arguments

.data

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

n

Number of times previous expression shall be repeated. For exact number of repetitions use single number. Use sequence min:max or vector of c(min, max) to denote range of repetitions. To create ranges unbounded on one end, pass on a vector with either first of second element equal to NA, e.g. c(NA, 3), up to 3 repetitions.

Examples

Run this code
# NOT RUN {
rx_count()

# create an expression
x <- rx_find(value = "a") %>%
  rx_count(3)

# create input
input <- "aaa"

# extract match
regmatches(input, regexpr(x, input))

# }

Run the code above in your browser using DataLab