# will produce lints
lint(
text = 'grepl("^a", x)',
linters = string_boundary_linter()
)
lint(
text = 'grepl("z$", x)',
linters = string_boundary_linter()
)
# okay
lint(
text = 'startsWith(x, "a")',
linters = string_boundary_linter()
)
lint(
text = 'endsWith(x, "z")',
linters = string_boundary_linter()
)
# If missing values are present, the suggested alternative wouldn't be strictly
# equivalent, so this linter can also be turned off in such cases.
lint(
text = 'grepl("z$", x)',
linters = string_boundary_linter(allow_grepl = TRUE)
)
Run the code above in your browser using DataLab