Learn R Programming

qdapRegex (version 0.5.1)

explain: Visualize Regular Expressions

Description

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

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 no
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.

Details

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

References

http://stackoverflow.com/a/27489977/1000343 http://www.regexper.com http://stackoverflow.com/a/27574103/1000343

See Also

http://www.regexper.com

Examples

Run this code
explain("\\s*foo[A-Z]\\d{2,3}", open = FALSE)
explain("@rm_time", open = FALSE)
## Opens the regex
explain("\\s*foo[A-Z]\\d{2,3}")
explain("@rm_time")

Run the code above in your browser using DataLab