Skip to content

Commit f0806c5

Browse files
dont escape slashes preceding double quoutes in deparse
1 parent c382298 commit f0806c5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
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,

0 commit comments

Comments
 (0)