rx_something: Match any character(s) at least once.

View source: R/rules.R

rx_somethingR Documentation

Match any character(s) at least once.

Description

This expression is almost identical to rx_anything() with one major exception, a + is used instead of a *. This means rx_something() expects something whereas anything() expects anything including... nothing!

Usage

rx_something(.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

Metacharacters: https://www.regular-expressions.info/characters.html#special

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

Examples

rx_something()

# construct an expression
x <- rx_something()

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


VerbalExpressions/RVerbalExpressions documentation built on March 27, 2024, 8:20 a.m.