|
|
|
|
|
|
|
|
req(replacement()) |
|
|
req(replacement()) |
|
|
regexFn( |
|
|
regexFn( |
|
|
rtext(), |
|
|
rtext(), |
|
|
stringr::regex( |
|
|
|
|
|
|
|
|
stringr_regex( |
|
|
pattern(), |
|
|
pattern(), |
|
|
ignore_case = 'ignore.case' %in% input$regex_options, |
|
|
ignore_case = 'ignore.case' %in% input$regex_options, |
|
|
literal = 'fixed' %in% input$regex_options |
|
|
literal = 'fixed' %in% input$regex_options |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
regexFn( |
|
|
regexFn( |
|
|
rtext(), |
|
|
rtext(), |
|
|
stringr::regex( |
|
|
|
|
|
|
|
|
stringr_regex( |
|
|
pattern(), |
|
|
pattern(), |
|
|
ignore_case = 'ignore.case' %in% input$regex_options, |
|
|
ignore_case = 'ignore.case' %in% input$regex_options, |
|
|
literal = 'fixed' %in% input$regex_options |
|
|
literal = 'fixed' %in% input$regex_options |
|
|
|
|
|
|
|
|
print(x) |
|
|
print(x) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
stringr_regex <- function(pattern, ignore_case = FALSE, literal = FALSE) { |
|
|
|
|
|
if (!requireNamespace("stringr", quietly = TRUE)) return(NULL) |
|
|
|
|
|
do.call( |
|
|
|
|
|
eval(parse(text = "stringr::regex")), |
|
|
|
|
|
list(pattern = pattern, ignore_case, ignore_case, literal = literal) |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
# ---- Server - Tab - Help ---- |
|
|
# ---- Server - Tab - Help ---- |
|
|
HELP_DEFAULT_TEXT <- c( |
|
|
HELP_DEFAULT_TEXT <- c( |
|
|
"<h3>Welcome to RegExplain</h3>", |
|
|
"<h3>Welcome to RegExplain</h3>", |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
observeEvent(input$help_try_this_hs_colors_text, { |
|
|
observeEvent(input$help_try_this_hs_colors_text, { |
|
|
color_match <- "\\b(red|orange|yellow|green|blue|purple)\\b|red" |
|
|
color_match <- "\\b(red|orange|yellow|green|blue|purple)\\b|red" |
|
|
color_text <- stringr::sentences[grepl(color_match, stringr::sentences)] |
|
|
|
|
|
color_text <- sample(color_text, 25) |
|
|
|
|
|
updateTextAreaInput(session, "text", value = paste(color_text, collapse = "\n")) |
|
|
|
|
|
showNotification("Text loaded! View it in Text tab", type = 'message') |
|
|
|
|
|
|
|
|
if (requireNamespace("stringr", quietly = TRUE)) { |
|
|
|
|
|
color_text <- stringr::sentences[grepl(color_match, stringr::sentences)] |
|
|
|
|
|
color_text <- sample(color_text, 25) |
|
|
|
|
|
updateTextAreaInput(session, "text", value = paste(color_text, collapse = "\n")) |
|
|
|
|
|
showNotification("Text loaded! View it in Text tab", type = 'message') |
|
|
|
|
|
} else { |
|
|
|
|
|
showNotification("Please install {stringr} for this example", type = 'error') |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
observeEvent(input$help_try_this_hs_colors_pattern, { |
|
|
observeEvent(input$help_try_this_hs_colors_pattern, { |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
observeEvent(input$help_try_this_hs_words_text, { |
|
|
observeEvent(input$help_try_this_hs_words_text, { |
|
|
hs_text <- sample(stringr::sentences, 25) |
|
|
|
|
|
updateTextAreaInput(session, "text", value = paste(hs_text, collapse = "\n")) |
|
|
|
|
|
showNotification("Text loaded! View it in Text tab", type = 'message') |
|
|
|
|
|
|
|
|
if (requireNamespace("stringr", quietly = TRUE)) { |
|
|
|
|
|
hs_text <- sample(stringr::sentences, 25) |
|
|
|
|
|
updateTextAreaInput(session, "text", value = paste(hs_text, collapse = "\n")) |
|
|
|
|
|
showNotification("Text loaded! View it in Text tab", type = 'message') |
|
|
|
|
|
} else { |
|
|
|
|
|
showNotification("Please install {stringr} for this example", type = 'error') |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
observeEvent(input$help_try_this_hs_words_pattern, { |
|
|
observeEvent(input$help_try_this_hs_words_pattern, { |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
observeEvent(input$help_try_this_hs_refs_text, { |
|
|
observeEvent(input$help_try_this_hs_refs_text, { |
|
|
hs_text <- sample(stringr::sentences, 25) |
|
|
|
|
|
updateTextAreaInput(session, "text", value = paste(hs_text, collapse = "\n")) |
|
|
|
|
|
showNotification("Text loaded! View it in Text tab", type = 'message') |
|
|
|
|
|
|
|
|
if (requireNamespace("stringr", quietly = TRUE)) { |
|
|
|
|
|
hs_text <- sample(stringr::sentences, 25) |
|
|
|
|
|
updateTextAreaInput(session, "text", value = paste(hs_text, collapse = "\n")) |
|
|
|
|
|
showNotification("Text loaded! View it in Text tab", type = 'message') |
|
|
|
|
|
} else { |
|
|
|
|
|
showNotification("Please install {stringr} for this example", type = 'error') |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
observeEvent(input$help_try_this_hs_refs_pattern, { |
|
|
observeEvent(input$help_try_this_hs_refs_pattern, { |