Skip to content

AdamSpannbauer/r_regex_tester_app

Repository files navigation

R Regex Tester Shiny App

Build Status Codecov test coverage CRAN_Status_Badge Last Commit

Usage

Online

Local

  • Install package
# Option 1: install from CRAN
install.packages("regexTestR")

# Option 2: install dev version from github
devtools::install_github("AdamSpannbauer/r_regex_tester_app")
  • Run app
regexTestR::run_app()

Features

Options

  • The other 2 options concerning backslashes allow you to write an R flavored regex.
    • For example, if you want to match a literal period with a regex you'll type "\\." (as if you were writing the regex in R).
    • If you don't like this behavior, and you'd rather type half of the slashes needed to make the regex functional in R, you can select the "Auto Escape Backslashes" option for "Pattern" and then use "\." to match literal periods in the app.

Input

  • There are 2 text inputs:
    1. Matching Pattern: type the regular expression or fixed pattern here that you want to use to match against your text.
    2. Test String: type the text that you want your Matching Pattern to search through

Results

  • After the pattern and test string are entered we see 2 different versions of the resulting pattern matching:
    1. The test string is shown with the matches/capture groups highlighted where they appear in the text
      • As noted in the UI, currently nested capture group highlighting isn't supported. If our matching pattern was "t(e(s))(t)" the highlighting wouldn't display correctly.
    2. The second output is a bulleted list of the matches and capture groups found in our test string. In the screen shot below we see we matched 2 instances of "test", and each of these matches display below them the contents of the 2 capture groups we included in our regex pattern.

Regex Explanation

  • There's additionally a collapsable panel that will do it's best to break down your regex and explain the components. As noted in the UI these explanations are provided by rick.measham.id.au
  • The screen shot below shows the explanation for our regex: "t(es)(t)"

Helping Documentation

  • The app includes some documentation for using regular expressions in R. The two including pieces of helping documentaion are:
    1. The RStudio Regex Cheatsheet
    2. The base R documentation on regex (this is what would appear if you ran the command ?regex)

Extra

Shiny's bootstrap roots allow apps to transition between desktop and mobile pretty seamlessly. The app's mobile experience isn't terrible, so you can use it for all your regex-ing fun on the go! (I won't ask why)