rx_something_but: Match any character(s) except these at least once.

View source: R/rules.R

rx_something_butR Documentation

Match any character(s) except these at least once.

Description

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

Usage

rx_something_but(.data = NULL, value, mode = "greedy")

Arguments

.data

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

value

Expression to optionally match

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_but(value = "abc")

# create an expression
x <- rx_something_but(value = "python")

grepl(x, "R")  # should be true
grepl(x, "py") # should be false


RVerbalExpressions documentation built on May 29, 2024, 6:47 a.m.