A friendly interface for the construction of regular expressions.
Regular expressions are very powerful feature, however they are often difficult to interpret. Rex allows you to build complex regular expressions from human readable expressions. So instead of writing (and later trying to decipher)
r <- "^(?:(((?:[^:])+)://))?((?:(?:(?!:/).)*)+)(?:(:([[:digit:]]+)))?(?:(/.*))?$"
You can write
r <- rex(start,## match the protocol -- may exist or may notmaybe(capture(capture(except_some_of(":")),"://")),## match the pathcapture(one_or_more(not(":/"))),## get the portmaybe(capture(":", capture(numbers))),## and the restmaybe(capture("/", anything)),end)
While these expressions are a big longer than their corresponding regular expression, they are much more readable and maintainable.
The vignettes have longer form usage examples.
rex() function call can include a number of functions and shortcuts.
For a full list of the functions available please see
Rex functions are not exported because they are only useful within
calls, but they can be temporarily attached using
rex_mode() which allows
them to be auto-completed.
rex in other packages will generate spurious NOTEs from
R CMD check
unless you include a call to
rex::register_shortcuts() with your package name
somewhere in your package source. This function registers all of the rex
shortcuts as valid variables fixing the NOTEs.
Updating tests to work with testthat version 220.127.116.1100.
substitutes aliases for
locations = TRUE
:operator for character ranges