The goal of RVerbalExpressions is to make it easier to construct regular expressions using grammar and functionality inspired by VerbalExpressions. Usage of %>% is encouraged to build expressions in a chain like fashion.

There are a couple of functions missing from the original JSVerbalExpressions:

  1. replace isn’t included because there are numerous R functions for this, gsub being one example
  2. add is a utility function for appending expressions to one another and isn’t included because we use %>% for that
  3. then is not included because the pipe %>% is often pronounced “then” and rx_find provides the same functionality
  4. any is not included because it collides with base::any() and rx_any_of provides the same functionality

Others just haven’t made it yet, see here.

Installation

You can install RVerbalExpressions from GitHub with:

# install.packages("devtools")
devtools::install_github("VerbalExpressions/RVerbalExpressions")

Example

This is a basic example which shows you how to build a regular expression:

Other Implementations

You can see an up to date list of all ports on VerbalExpressions.github.io.

Additionally, there are two R packages that try to solve the same problem. I encourage you to check these out:

  1. rex by @kevinushey
  2. rebus by @richierocks

Contributing

If you find any issues, please file an issue or submit a PR. All contributions are welcome! See the list of todo items here if you’re looking for something to specific to work on.