Skip to content

More fixed_regex_linter features #1166

Closed
@AshesITR

Description

@AshesITR

There are some more cases where regexes can be optimized away:

For regex detection functions, we can safely replace

  • grepl("^static_rx", x) by startsWith(x, "static_rx")
  • grepl("static_rx$", x) by endsWith(x, "static_rx")
  • grepl("^static_rx$", x) by x == "static_rx"

For substitution functions, we can replace

  • gsub("^static_rx$", "replacement", x) by (function(.) { .[. == "static_rx"] <- "replacement"; . })(x)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions