# will produce lints
code_lines <- 'gsub("\\\\.", "", x)'
writeLines(code_lines)
lint(
text = code_lines,
linters = fixed_regex_linter()
)
lint(
text = 'grepl("a[*]b", x)',
linters = fixed_regex_linter()
)
lint(
text = 'grepl("a[*]b", x)',
linters = fixed_regex_linter(allow_unescaped = TRUE)
)
code_lines <- 'stringr::str_subset(x, "\\\\$")'
writeLines(code_lines)
lint(
text = code_lines,
linters = fixed_regex_linter()
)
lint(
text = 'grepl("Munich", address)',
linters = fixed_regex_linter()
)
# okay
code_lines <- 'gsub("\\\\.", "", x, fixed = TRUE)'
writeLines(code_lines)
lint(
text = code_lines,
linters = fixed_regex_linter()
)
lint(
text = 'grepl("a*b", x, fixed = TRUE)',
linters = fixed_regex_linter()
)
lint(
text = 'stringr::str_subset(x, stringr::fixed("$"))',
linters = fixed_regex_linter()
)
lint(
text = 'grepl("Munich", address, fixed = TRUE)',
linters = fixed_regex_linter()
)
lint(
text = 'grepl("Munich", address)',
linters = fixed_regex_linter(allow_unescaped = TRUE)
)
Run the code above in your browser using DataLab