Is it possible to implement a function that matches regular expressions against strings…
- User
Is it possible to implement a function that matches regular expressions against strings in bazel starlark? If so, show me an example
- Assistant
Unfortunately, Starlark, the dialect of Python that Bazel uses, does not support regular expressions or any form of string manipulation beyond basic concatenation and comparison. The language is intentionally limited to prevent complex operations in the build configuration.
However, you can create a genrule or a custom rule that uses a Python script or another tool capable of regex operations. Here's an example of a genrule:
genrule( name = "regex_operation", srcs = ["input.txt"], outs = ["output.txt"], cmd = "python $(location :regex_script.py) < $(SRCS) > $@", tools = [":regex_script.py"], )
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.