Skip to content

[FR] regex substitution support in expand_template #1192

@peakschris

Description

@peakschris

It would be very helpful to be able to match using regex in expand_template:

expand_template(
  regex_substitutions = {
      "^whole_line$": "replace_whole_line"
      "capture (\w+) something": "use $1 in a replacement"
      "^delete_line$\n": ""
  }
)

It seems like a fairly straightforward implementation given https://github.com/bazel-contrib/bazel-lib/blob/main/tools/expand_template/main.go already exists; we would always use this engine when regex_substitutions was set.

We could contribute this; would it be welcome?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions