|
|
|
@@ -290,13 +290,79 @@ regex_gadget <- function(text = NULL, |
|
|
|
}) |
|
|
|
|
|
|
|
# ---- Server - Tab - Help ---- |
|
|
|
HELP_DEFAULT_TEXT <- paste0( |
|
|
|
HELP_DEFAULT_TEXT <- c( |
|
|
|
"<div id=\"welcome-to-regexplain\" class=\"section level3\">", |
|
|
|
"<h3>Welcome to RegExplain</h3>", |
|
|
|
"<p>Choose a category from the menu on the left.</p>" |
|
|
|
) |
|
|
|
"<p>If you’re new to regular expressions, one of the best places to start is <a href=\"http://stringr.tidyverse.org/articles/regular-expressions.html\">the regular expressions vignette</a> from <code>stringr</code>. The chapter on strings in <a href=\"http://r4ds.had.co.nz/strings.html\">R for Data Science</a> is also an excellent first resource.</p>", |
|
|
|
"<p><strong>Exploring or looking for a challenge?</strong> Click on <i>Try These Examples</i> to see what you can do with this addin.</p>", |
|
|
|
"<div id=\"getting-started\" class=\"section level4\">", |
|
|
|
"<h4>Getting Started</h4>", |
|
|
|
"<ul>", |
|
|
|
"<li><p><i class=\"fa fa-file-text-o\"></i> Enter or edit the <strong>Text</strong> you want to search.</p></li>", |
|
|
|
"<li><p><i class=\"fa fa-terminal\"></i> Edit your <strong>RegEx</strong> and view matches in real time.</p></li>", |
|
|
|
"<li><p><i class=\"fa fa-table\"></i> Test the <strong>Output</strong> of your regular expression with common functions, including <i>search and replace</i> functions.</p></li>", |
|
|
|
"<li><p><i class=\"fa fa-support\"></i> Get <strong>Help</strong> and look up the regular expression syntax.</p></li>", |
|
|
|
"</ul>", |
|
|
|
"</div>", |
|
|
|
"<div id=\"escaping-characters\" class=\"section level4\">", |
|
|
|
"<h4>Escaping characters</h4>", |
|
|
|
"<p>In order to store a backslash (<code>\\</code>) as a character in R, backslashes need to be escaped…with another backslash! To write a literal <code>\\</code> in an R character string, you need to actually store <code>"\\\\"</code>.</p>", |
|
|
|
"<p>In regular expressions, <code>\\w</code> stands for any alphabetical character, but to store it in a string in R you need <code>"\\w"</code>.</p>", |
|
|
|
"<p>Inside <strong>RegExplain</strong>, however, standard regular expressions can be used so that you can easily copy patterns from other places. When you click on the <span class=\"btn btn-xs btn-primary\">Send RegEX to Console</span> button, the necessary extra <code>\\</code> will be included.</p>", |
|
|
|
"<p>An extra backslash is still needed to match a literal <code>\\</code> in standard regular expressions. This means that you will need to enter <code>\\\\</code> in the <strong>RegEx</strong> tab, and the output to R will be <code>"\\\\\\\\"</code>.</p>", |
|
|
|
"</div>") |
|
|
|
|
|
|
|
source(system.file("shiny", "help_server.R", package = "regexplain"), local = TRUE) |
|
|
|
|
|
|
|
observeEvent(input$help_resources, { |
|
|
|
tagList( |
|
|
|
tags$h3("Resources"), |
|
|
|
tags$p("There are lots of great resources available for learning and working with regular expressions."), |
|
|
|
tags$h4("Regular Expressions in R"), |
|
|
|
tags$ul( |
|
|
|
tags$li(tags$p("The", tags$a(href = "http://stringr.tidyverse.org/articles/regular-expressions.html", "Regular Expressions vignette"), |
|
|
|
"from", tags$code("stringr"), "is an excellent first introduction to regular expressions in R.")), |
|
|
|
tags$li(tags$p("The", tags$a(href = "http://r4ds.had.co.nz/strings.html", "chapter on strings"), |
|
|
|
"in", tags$a(href = "http://r4ds.had.co.nz/", "R for Data Science"), |
|
|
|
"is also a great overall introduction.")), |
|
|
|
tags$li(tags$p("RStudio's", |
|
|
|
tags$a(href = "https://www.rstudio.com/wp-content/uploads/2016/09/RegExCheatsheet.pdf", "RegEx CheatSheet"), |
|
|
|
"is a good pocket reference.")), |
|
|
|
tags$li(tags$p("Or try the", tags$strong("Regexplain Cheatsheet"), "addin installed with this package.")) |
|
|
|
), |
|
|
|
tags$h4("Online Resources"), |
|
|
|
tags$ul( |
|
|
|
tags$li(tags$a(href = "https://github.com/aloisdg/awesome-regex", "Awesome RegEx")), |
|
|
|
tags$li(tags$a(href = "https://www.regular-expressions.info", "Regular-Expressions.info")) |
|
|
|
), |
|
|
|
tags$h4("Live Preview and Explanations"), |
|
|
|
tags$ul( |
|
|
|
tags$li(tags$a(href = "https://regexr.com", "https://regexr.com")), |
|
|
|
tags$li(tags$a(href = "https://debuggex.com", "https://debuggex.com")), |
|
|
|
tags$li(tags$a(href = "https://regex101.com", "https://regex101.com")), |
|
|
|
tags$li(tags$a(href = "http://www.mactechnologies.com/index.php?page=downloads#regexrx", "RegexRx"), "(app)"), |
|
|
|
tags$li(tags$a(href = "https://www.regexbuddy.com/", "Regex Buddy"), "(paid app)") |
|
|
|
), |
|
|
|
tags$h4("Regex and String R Packages"), |
|
|
|
tags$dl( |
|
|
|
tags$dt(tags$a(href = "https://stringr.tidyverse.org/", "stringr")), |
|
|
|
tags$dd("A cohesive set of functions designed to make working with strings as easy as possible"), |
|
|
|
tags$dt(tags$a(href = "http://www.gagolewski.com/software/stringi/", "stringi")), |
|
|
|
tags$dd("THE R package for very fast, correct, consistent, and convenient string/text processing"), |
|
|
|
tags$dt(tags$a(href = "https://github.com/trinker/regexr", "regexr")), |
|
|
|
tags$dd("An R framework for constructing and managing human readable regular expressions"), |
|
|
|
tags$dt(tags$a(href = "https://github.com/kevinushey/rex", "rex")), |
|
|
|
tags$dd("Friendly Regular Expressions: complex regular expressions from human readable expressions"), |
|
|
|
tags$dt(tags$a(href = "https://github.com/richierocks/rebus", "rebus")), |
|
|
|
tags$dd("Build regular expressions in a human readable way"), |
|
|
|
tags$dt(tags$a(href = "https://github.com/AdamSpannbauer/r_regex_tester_app", "R Regex Tester")), |
|
|
|
tags$dd("A Shiny app for testing regular expressions") |
|
|
|
) |
|
|
|
) %>% |
|
|
|
as.character() %>% |
|
|
|
help_text() |
|
|
|
}) |
|
|
|
|
|
|
|
load_buttons <- function(..., extra_btns = NULL) { |
|
|
|
prefix <- paste(..., sep = "_") |
|
|
|
btns <- c( |