Title: | Rstudio Addin to Explain, Test and Build Regular Expressions |
---|---|
Description: | A set of RStudio Addins to help interactively test and build regular expressions. Provides a Shiny gadget interface for interactively constructing the regular expression and viewing the results from common string-searching functions. The gadget interface includes a helpful regex syntax reference sheet and a library of common patterns. |
Authors: | Garrick Aden-Buie [aut, cre], Winston Chang [ctb] (Author of textInput and textAreaInput fragments from shiny), Yihui Xie [ctb] (Author of escape_html fragment from highr), RStudio [cph] (Copyright holder of included shiny fragments) |
Maintainer: | Garrick Aden-Buie <[email protected]> |
License: | GPL-3 |
Version: | 0.2.2.9000 |
Built: | 2024-11-09 05:38:38 UTC |
Source: | https://github.com/gadenbuie/regexplain |
Extract matched groups from regexp
regex( text, pattern, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE, global = TRUE )
regex( text, pattern, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE, global = TRUE )
text |
Text to search |
pattern |
regexp |
ignore.case |
if |
perl |
logical. Should Perl-compatible regexps be used? |
fixed |
logical. If |
useBytes |
logical. If |
global |
If |
The function behind the RegExplain Cheatsheet addin. Opens a summary of regular expression syntax – the RegExplain cheatsheet – in an RStudio viewer pane.
regexplain_cheatsheet()
regexplain_cheatsheet()
The function behind the RegExplain Selection and RegExplain File addins. Opens the RegExplain gadget interface in an RStudio viewer pane.
regexplain_file(pattern = NULL, start_page = "RegEx") regexplain_gadget( text = NULL, pattern = NULL, start_page = if (is.null(text)) "Text" else "RegEx" ) regexplain_web(text = NULL, pattern = NULL, start_page = "Text", ...)
regexplain_file(pattern = NULL, start_page = "RegEx") regexplain_gadget( text = NULL, pattern = NULL, start_page = if (is.null(text)) "Text" else "RegEx" ) regexplain_web(text = NULL, pattern = NULL, start_page = "Text", ...)
pattern |
Regular Expression to edit or visualize using RegExplain |
start_page |
Open gadget to this tab, one of |
text |
Text to explore in gadget (editable using interface) |
... |
Arguments passed on to
|
The regular expression built in the app is returned as a character string.
regexplain_file
: Opens file chooser to pick file, reads lines,
returns first regexplain.addin.max_lines
(default 100). Used in the
"Regexplain File" regexplain_addin.
regexplain_web
: Launches the RegExplain gadget in a browser or an
RStduio viewer pane.
## Not run: regexplain_gadget(text = month.name, pattern = "(Ma|Ju)|(er)") regexplain_web(text = month.name, pattern = "(Ma|Ju)|(er)") regexplain_file() ## End(Not run)
## Not run: regexplain_gadget(text = month.name, pattern = "(Ma|Ju)|(er)") regexplain_web(text = month.name, pattern = "(Ma|Ju)|(er)") regexplain_file() ## End(Not run)
Standard shiny::textAreaInput()
with additional is_code
parameter, added
code font style for the input text and with autocomplete
, autocorrect
,
autocapitalize
and spellcheck
set to off
or false
.
textAreaInputAlt( inputId, label, value = "", width = NULL, height = NULL, cols = NULL, rows = NULL, placeholder = NULL, resize = NULL, is_code = TRUE )
textAreaInputAlt( inputId, label, value = "", width = NULL, height = NULL, cols = NULL, rows = NULL, placeholder = NULL, resize = NULL, is_code = TRUE )
inputId |
The |
label |
Display label for the control, or |
value |
Initial value. |
width |
The width of the input, e.g. |
height |
The height of the input, e.g. |
cols |
Value of the visible character columns of the input, e.g. |
rows |
The value of the visible character rows of the input, e.g. |
placeholder |
A character string giving the user a hint as to what can be entered into the control. Internet Explorer 8 and 9 do not support this option. |
resize |
Which directions the textarea box can be resized. Can be one of
|
is_code |
Should the text input be considered verbatim code input? |
Other modified shiny inputs:
textInputCode()
Standard shiny::textInput()
with additional width
parameter, added code
font style for the input text and with autocomplete
, autocorrect
,
autocapitalize
and spellcheck
set to off
or false
.
textInputCode( inputId, label, value = "", width = NULL, placeholder = NULL, ... )
textInputCode( inputId, label, value = "", width = NULL, placeholder = NULL, ... )
inputId |
The |
label |
Display label for the control, or |
value |
Initial value. |
width |
Width of |
placeholder |
A character string giving the user a hint as to what can be entered into the control. Internet Explorer 8 and 9 do not support this option. |
... |
Extra elements to be included in the |
Other modified shiny inputs:
textAreaInputAlt()
View the result of the regular expression when applied to the given text.
The default behavior renders the result as HTML and opens the file in
the RStudio viewer pane. If render
is FALSE
, the HTML itself is returned.
If the output is destined for a knitr document, set knitr
to TRUE
.
view_regex( text, pattern, ..., render = TRUE, escape = render, exact = escape, result_only = FALSE )
view_regex( text, pattern, ..., render = TRUE, escape = render, exact = escape, result_only = FALSE )
text |
Text to search |
pattern |
Regex pattern to look for |
... |
Arguments passed on to
|
render |
Render results as HTML? |
escape |
Escape HTML-related characters in |
exact |
Should the regex pattern be displayed as entered by the user
into R console or source (default)? When |
result_only |
Should only the result be displayed? If |
view_regex("example", "amp", render = FALSE)
view_regex("example", "amp", render = FALSE)