Skip to content

Commit 6acd614

Browse files
Merge pull request #13 from AdamSpannbauer/perl_12
Fix look ahead/behinds and quote issue
2 parents b9e798d + f0806c5 commit 6acd614

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

r_regex_tester/helper_functions.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ library(data.table)
33
half_slashes = function(str) {
44
deparsed = deparse(str)
55

6-
half_df = data.table::as.data.table(stringr::str_match_all(deparsed, "(\\\\+)(.)")[[1]])
6+
half_df = data.table::as.data.table(stringr::str_match_all(deparsed, "(\\\\)(.)")[[1]])
77
data.table::setnames(half_df, c("match","slash_cap","char_cap"))
88
half_df[, half_slash := stringr::str_sub(slash_cap,
99
end=(nchar(slash_cap)/2))]
1010
half_df[, out := paste0(half_slash, char_cap)]
1111
half_df = unique(half_df[order(nchar(out)), ])
1212

13+
# Removing slashes before double quoutes breaks eval
14+
half_df = half_df[char_cap != '"']
15+
1316
halfed_deparse = mgsub(half_df$match,
1417
half_df$out,
1518
deparsed,

r_regex_tester/server.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ shinyServer(function(input, output, session){
1212
input$pattern,
1313
safe_slashes(input$pattern))
1414

15-
htmltools::htmlEscape(pattern)
15+
pattern
1616
})
1717

1818
test_str = reactive({
@@ -21,8 +21,8 @@ shinyServer(function(input, output, session){
2121
test_str = ifelse("test_str" %in% input$auto_escape_check_group,
2222
input$test_str,
2323
safe_slashes(input$test_str))
24-
25-
htmltools::htmlEscape(test_str)
24+
25+
test_str
2626
})
2727

2828
match_list = reactive({

r_regex_tester/ui.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ shinyUI(
8888
HTML("<strong><font size='5'>Input</font></strong><hr>"),
8989
textInput("pattern", label="Matching Pattern", value="t(es)(t)",
9090
placeholder="Enter regex to match", width="100%"),
91-
textAreaInput("test_str", label="Test String", value="This is a test string for testing regex.",
92-
placeholder="Enter string to match regex against",width="100%")
91+
textAreaInput("test_str",
92+
label=HTML("Test String (<a href='https://stackoverflow.com/a/1732454/5731525' target='_blank'>HTML tags are not supported</a>)"),
93+
value="This is a test string for testing regex.",
94+
placeholder="Enter string to match regex against",
95+
width="100%")
9396
),
9497
bsCollapse(id = "collapseExample",
9598
bsCollapsePanel(HTML("<strong><font size='5'>Reg-Explanation</font></strong>"),

0 commit comments

Comments
 (0)