- Visit the application live on shinyapps.io.
- 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()
- Use the common options used across the R Pattern Matching and Replacement family of functions.
- 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.
- There are 2 text inputs:
- Matching Pattern: type the regular expression or fixed pattern here that you want to use to match against your text.
- Test String: type the text that you want your Matching Pattern to search through
- After the pattern and test string are entered we see 2 different versions of the resulting pattern matching:
- 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.
- 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.
- The test string is shown with the matches/capture groups highlighted where they appear in the text
- 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)"
- The app includes some documentation for using regular expressions in R. The two including pieces of helping documentaion are:
- The RStudio Regex Cheatsheet
- The base R documentation on regex (this is what would appear if you ran the command
?regex
)
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)