All Projects → gadenbuie → Regexplain

gadenbuie / Regexplain

Licence: other
🔍 An RStudio addin slash regex utility belt

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Regexplain

pirate
🏴‍☠️ A personal platform for R programming
Stars: ✭ 36 (-91.28%)
Mutual labels:  shiny, rstats
Rex
Your RegEx companion.
Stars: ✭ 283 (-31.48%)
Mutual labels:  regex, regular-expression
tRakt-shiny
Using trakt to graph show data and such. The on-it's-way-out incarnation of trakt.jemu.name
Stars: ✭ 17 (-95.88%)
Mutual labels:  shiny, rstats
extglob
Extended globs. Add (almost) the expressive power of regular expressions to glob patterns.
Stars: ✭ 25 (-93.95%)
Mutual labels:  regex, regular-expression
Picomatch
Blazing fast and accurate glob matcher written JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.
Stars: ✭ 393 (-4.84%)
Mutual labels:  regex, regular-expression
workshops-setup cloud analytics machine
Tips and Tricks to setup a cloud machine for Analytics and Data Science with R, RStudio and Shiny Servers, Python and JupyterLab
Stars: ✭ 12 (-97.09%)
Mutual labels:  shiny, rstats
Re Flex
The regex-centric, fast lexical analyzer generator for C++ with full Unicode support. Faster than Flex. Accepts Flex specifications. Generates reusable source code that is easy to understand. Introduces indent/dedent anchors, lazy quantifiers, functions for lex/syntax error reporting, and more. Seamlessly integrates with Bison and other parsers.
Stars: ✭ 274 (-33.66%)
Mutual labels:  regex, regular-expression
regex-cache
Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in dramatic speed improvements.
Stars: ✭ 39 (-90.56%)
Mutual labels:  regex, regular-expression
Generex
A Java library for generating String from a regular expression.
Stars: ✭ 316 (-23.49%)
Mutual labels:  regex, regular-expression
Regex
Regular expressions for swift
Stars: ✭ 306 (-25.91%)
Mutual labels:  regex, regular-expression
genex
Genex package for Go
Stars: ✭ 64 (-84.5%)
Mutual labels:  regex, regular-expression
Minta
✳️  Electron app for generating regular expressions
Stars: ✭ 353 (-14.53%)
Mutual labels:  regex, regular-expression
hex-color-regex
Regular expression for matching hex color values from string.
Stars: ✭ 29 (-92.98%)
Mutual labels:  regex, regular-expression
waypointer
Waypoints & Animations for Shiny
Stars: ✭ 16 (-96.13%)
Mutual labels:  shiny, rstats
r-ladies-ML-1
⭐ Files for my R-Ladies ML workshop - Supervised Learning 101 ⭐
Stars: ✭ 35 (-91.53%)
Mutual labels:  shiny, rstats
pcre-net
PCRE.NET - Perl Compatible Regular Expressions for .NET
Stars: ✭ 114 (-72.4%)
Mutual labels:  regex, regular-expression
RgxGen
Regex: generate matching and non matching strings based on regex pattern.
Stars: ✭ 45 (-89.1%)
Mutual labels:  regex, regular-expression
pamatcher
A pattern matching library for JavaScript iterators
Stars: ✭ 23 (-94.43%)
Mutual labels:  regex, regular-expression
Anymatch
‼️ Matches strings against configurable strings, globs, regular expressions, and/or functions
Stars: ✭ 289 (-30.02%)
Mutual labels:  regex, regular-expression
Waiter
🕰️ Loading screens for Shiny
Stars: ✭ 325 (-21.31%)
Mutual labels:  shiny, rstats

RegExplain

Regular expressions are tricky. RegExplain makes it easier to see what you’re doing.

Project Status: Active – The project has reached a stable, usable state and is being actively developed. CRAN_Status_Badge

RegExplain is an RStudio addin slash utility belt for regular expressions. Interactively build your regexp, check the output of common string matching functions, consult the interactive help pages, or use the included resources to learn regular expressions. And more.

Inspired by RegExr.com and stringr::str_view().

Installation

Installation is easy with remotes

# install.packages("remotes")
remotes::install_github("gadenbuie/regexplain")

RegExplain in Action

Overview

regexplain selection

Regular Expressions Library

regexplain library

Try the Built-In Examples

regexplain examples

RStudio Addin

The main feature of this package is the RStudio Addin RegExplain Selection. Just select the text or object containing text (such as the variable name of a vector or a data.frame column) and run RegExplain Selection from the RStudio Addins dropdown.

regexplain in the Rstudio Addins dropdown

You can also open the addin with regexplain_gadget(). This allows you to pass text or a regular expression to the gadget, which is useful when you want to work with a regular expression in your code or environment.

regexplain_gadget(text_vector, "\\b(red|blue|green): \\d{3}")

The addin will open an interface with 4 panes where you can

  • edit the text you’ve imported
  • build up a regex expression and interactively see it applied to your text
  • test the output of common string matching and replacement functions from base and stringr
  • and refer to a helpful cheatsheet

The panes of regexplain

When you’re done, click on the Send Regex to Console to send your regex expression to… the console!

> pattern <- "\\b(red|orange|yellow|green|blue|purple|white|brown)(?:\\s(\\w+))?"

Notice that RegExplain handled the extra backslashes needed for storing the RegEx characters \b, \s, and \w. Inside the gadget you can use regular old regular expressions as you found them in the wild (hello, Stack Overflow!).

Help and Cheat Sheet

The Help tab is full of resources, guides, and R packages and includes an easy-to-navigate reference of commonly used regular expression syntax.

regexplain help windows

Open RegExplain Cheatsheet from the RStudio Addins drop down to open the regex reference page in the Viewer pane without blocking your current R session.

Import Your Text

There are two ways to get your text into RegExplain. The first way was described above: select an object name or lines of text or code in the RStudio source pane and run RegExplain Selection. To import text from a file, use RegExplain File to you import the text you want to process with regular expressions.

When importing text, RegExplain automatically reduces the text to the unique entries and limits the number of lines.

regexplain addins

Regular Expressions Library

The RegExplain gadget includes a regular expressions library in the RegEx tab. The library features common regular expressions, sourced from qdapRegex and Regex Hub, with several additional patterns.

The full library is stored as a JSON file in inst/extdata/patterns.json, feel free to contribute patterns you find useful or use regularly via pull request.

regexplain library modal

View Static Regex Results

RegExplain provides the function view_regex() that you can use as a stringr::str_view() replacement. In addition to highlighting matched portions of the text, view_regex() colorizes groups and attempts to colorize the regex expression itself as well.

text <- c("breakfast=eggs;lunch=pizza",
          "breakfast=bacon;lunch=spaghetti", 
          "no food here")
pattern <- "((\\w+)=)(\\w+).+(ch=s?p)"

view_regex(text, pattern)

Example view_regex(text, pattern).

t_nested <- "anestedgroupwithingroupexample"
r_nested <- "(a(nested)(group(within(group))(example)))"
view_regex(t_nested, r_nested)

Example of nested groups

Notes

Regular expressions are nothing if not a collection of corner cases. Trying to pass regular expressions through Shiny and HTML inputs is a bit of a labyrinth. For now, assume any issues or oddities you experience with this addin are entirely my fault and have nothing to do with the fine packages this addin is built on. If you do find an issue, please file an issue. Pull requests are welcomed!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].