Visualize Regular Expressions

Usage

explain(pattern, open = FALSE, print = TRUE, dictionary = getOption("regex.library"))

Arguments

pattern
A character string containing a regular expression or a character string starting with "@" that is a regular expression from a qdapRegex dictionary.
open
logical. If TRUE the default browser will attempt to open http://www.regexper.com page. Setting open = 2 will utilize an unstable visualization via https://www.debuggex.com. This approach utilizes a non-api scrape that is subject to change and not guaranteed to be stable. The regex is set to Python flavor which handles lookbehinds that the Java based http://www.regexper.com does not. This functionality was developed by Matthew Flickinger (see http://stackoverflow.com/a/27574103/1000343 for details). Note that the user must have httr installed or will be prompted if the package cannot be required.
print
logical. Should explain print output to the console?
dictionary
A dictionary of canned regular expressions to search within.

Value

Prints http://www.regexper.com to the console, attempts to open the url to the visual representation provided by http://www.regexper.com, and invisibly returns a list with the URLs.

Description

Visualize regular expressions using http://www.regexper.com

Details

Note that http://www.regexper.com is a Java based regular expression viewer. Lookbehind and negative lookbehinds are not respected.

Examples

explain("\\s*foo[A-Z]\\d{2,3}", open = FALSE)
The `http://rick.measham.id.au/paste/explain` text explanation no longer prints to the command line. The website no longer works. The text explanation functionality will return if the website becomes operational again or if a suitable substitute can be found.
http://www.regexper.com/#%5Cs*foo[A-Z]%5Cd%7B2,3%7D
explain("@rm_time", open = FALSE)
The `http://rick.measham.id.au/paste/explain` text explanation no longer prints to the command line. The website no longer works. The text explanation functionality will return if the website becomes operational again or if a suitable substitute can be found.
http://www.regexper.com/#%5Cd%7B0,2%7D:%5Cd%7B2%7D(?:[:.]%5Cd+)?
## <strong>Not run</strong>: # ## Opens the regex # explain("\\s*foo[A-Z]\\d{2,3}") # explain("@rm_time") # ## <strong>End(Not run)</strong>

See also

http://www.regexper.com

Author

Ananda Mahto, Matthew Flickinger, and Tyler Rinker .