gadenbuie / regexplain Goto Github PK
View Code? Open in Web Editor NEW๐ An RStudio addin slash regex utility belt
Home Page: https://www.garrickadenbuie.com/project/regexplain/
License: GNU General Public License v3.0
๐ An RStudio addin slash regex utility belt
Home Page: https://www.garrickadenbuie.com/project/regexplain/
License: GNU General Public License v3.0
When hitting "Send Regex To Console" in the Output tab, the console shows something like the following:
pattern <- "\w+ " # perl=TRUE
replacement <- "NO "
Wouldn't be better to integrate the parameters into the actual function used? In this case, it could translate into:
sub(pattern = "\w+",
replacement = "NO ",
x = readr::read_file("LICENSE"),
perl = TRUE)
Or maybe:
sub(pattern = "\w+",
replacement = "NO ",
x = YOUR_CHARACTER_VECTOR_HERE,
perl = TRUE)
Thanks for the awesome package!
Trying to use regexplain
via the addin or any of the functions in the package gives the same error indicating %AND%
not found.
Per our separate conversation offline, it sounds like this may be relying on a shiny
component that has now changed.
regexplain::regexplain_web(text = "https://cms.nhl.bamgrid.com/images/headshots/current/168x168/8478402.jpg", pattern = ".*[/]([^.]+)[.].*")
#> Error in get(x, envir = ns, inherits = FALSE): object '%AND%' not found
Created on 2021-01-27 by the reprex package (v0.3.0)
The gadget currently accepts text input via regexplain::regex_gadget(text)
. This works well for the addin where the current selection is passed to the gadget.
In working with a regexp, I often cycle between the source and the gadget, and it would be useful to be able to pass a regexp to the gadget as well, i.e. regexplain::regex_gadget(text, pattern)
.
As described in #9, there may be an issue coming up with R Studio version 1.2
As a possible related issue I have not succeeded in copying a regex with the send RegEx to Console button. The regexplain applet (?) just ends without visible indication that a copy is done (to console, editor or clipboard).
This happens even when I try to change '2017' in '2018' with gsub with the applet: in this case the RegEx and Output panel both show the expected display but the send RegEx to Console button only ends the applet.I am using RStudio Version 1.2.502 and R packages as listed below in sessionInfo.
The gadget currently shows the first match in each line akin to sub()
because this is how regexc()
works.
A global search option would be great, most likely by adding logic to remove the first match and re-run regexc()
on the remaining string.
Only the "Cheatsheeth" does launch despite the error message
regexplain:::regexplain_addin()
Error in get(x, envir = ns, inherits = FALSE) : object '%AND%' not found
RStudio
Version 1.4.1103
MacBook-Air M1
r --version
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)
Pretty sure that stringi
, stringr
and rematch2
can be in suggests. Either the gadget takes into account whether these functions are loaded or it should.
Hi!
Though I like any initiative to make regular expressions more convenient to use, I find most solutions to lack a visual understanding of the regex itself. Textual explanations of regular expressions don't really cut it IMHO. Probably the best source for visualising regex is Debuggex, which is unfortunately down with a gateway error half of the time. Would it be possible to include (something similar to) their awesome visual graphic as perhaps a new tab to your interface?
What I mean is this:
# example regex for validating email adresses, quite hard to read
^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$
Output by Debuggex (which is mainly powered by their static/js/main.js
):
If you want to replace or extract, say, the domain, you can immediately tell that you're looking for group 2 (\\2
). Might be obvious in this case, but for more complex expressions, this really matters and can save a lot of time.
How awesome would it be, if your Shiny app could convert this:
# example regex for matching IP addresses
^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
into this:
๐
Needs more investigation, but I think I only use dplyr and tidyr in a one or two places and can easily refactor to remove them as dependencies. See #9 for a reason why this would be a good idea (dplyr imports other packages, etc.).
Using rocker/verse c97e22aa5090
(I think), I get the following error
> view_regex(stringr::sentences[1:10], "(?:The )?([^ ]+) (?:is|was|were) ([^ ]+) (([^ ]+) (([^ ]+) ([^ ]+)))")
pandoc: theme:bootstrap: openFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
Hello Garrick,
just to let you know that this link:
https://apps.garrickadenbuie.com/regexplain
is error 502.
Thanks again for all the development you do, appreciate all your pkgs.
or drop the tidyr dependency
To reproduce:
str_replace
so that replacement input is generatedWarning: Error in if: missing value where TRUE/FALSE needed
Stack trace (innermost first):
68: observeEventHandler
4: shiny::runApp
3: runGadget
2: regex_gadget
1: regexplain:::regexplain_addin
ERROR: [on_request_read] connection reset by peer
Should be quick fix to check that input$replacement
is truthy.
Packages and resources
vignettes("regular-expressions", "stringr")
Online RegEx previews
Other regex and string related packages:
Other R/Shiny/Rstudio related packages:
Experimenting with the toolbox I tried to change text between parentheses. A pair of parentheses without any text in between is not handled correctly in the RegEx panel. However the Output panel shows the expected output. See end of this post.
As a possible related issue I have not succeeded in copying a regex with the send RegEx to Console button. The regexplain applet (?) just ends without visible indication that a copy is done (to console, editor or clipboard).
This happens even when I try to change '2017' in '2018' with gsub with the applet: in this case the RegEx and Output panel both show the expected display but the send RegEx to Console button only ends the applet.
I am using RStudio Version 1.2.502 and R packages as listed below in sessionInfo.
Thanks for bringing this software to the public domain.
sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] baseother attached packages:
[1] shiny_1.0.5 bindrcpp_0.2.2loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 rstudioapi_0.7 bindr_0.1.1
[4] magrittr_1.5 tidyselect_0.2.4 xtable_1.8-2
[7] R6_2.2.2 rlang_0.2.0 dplyr_0.7.4
[10] tools_3.4.1 miniUI_0.1.1 htmltools_0.3.6
[13] yaml_2.1.18 assertthat_0.2.0 digest_0.6.15
[16] tibble_1.4.2 regexplain_0.2.1 tidyr_0.8.0
[19] purrr_0.2.4 curl_3.1 glue_1.2.0
[22] mime_0.5 compiler_3.4.1 pillar_1.2.1
[25] jsonlite_1.5 httpuv_1.3.6.2 pkgconfig_2.0.1
The default branch of this repository is being moved from master
to main
. This issue will be closed when the default branch has been changed.
For help and guidance with updating the default branch of your local or forked copy of this repo, please see Renaming the default branch.
Search for files that may potentially reference master
.
ID: 91e77a361e4e
Test: "(?:The )?([^ ]+) is|was|were ([^ ]+) (([^ ]+) (([^ ]+) ([^ ]+)))"
Should not look like this:
Maybe because regexec
returns something like this:
[[4]]
[1] 22 22 0 0 0 0 0 0
attr(,"match.length")
[1] 6 3 0 0 0 0 0 0
attr(,"useBytes")
[1] TRUE
[[5]]
[1] 1 1 0 0 0 0 0 0
attr(,"match.length")
[1] 7 4 0 0 0 0 0 0
attr(,"useBytes")
[1] TRUE
Or is the regex fundamentally wrong?
After installing regexplain the following packages were deleted from my machine:
Very odd behavior.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.