Azure / Azure/bicep

Regular expression (regex / regexp) replace/match function

Open
#16,461 4 comments 6 reactions 0 assignees View on GitHub
enhancement intermediate language new function
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Is your feature request related to a problem? Please describe**
`replace` is useful, but sometimes simple string replacements aren't enough, and one needs regular expressions replacements. It can also help with multiple replacements as requested here: https://github.com/Azure/bicep/issues/5703.

Similarly, `contains` is useful but not as versatile as regex matching.

**Describe the solution you'd like**
1. A function like `replaceRegex` with a signature similar to [what we have in .NET](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.replace?view=net-9.0#system-text-regularexpressions-regex-replace(system-string-system-string-system-string-system-text-regularexpressions-regexoptions)): `public static string Replace(string input, string pattern, string replacement, System.Text.RegularExpressions.RegexOptions options)`
1. A function like `matchesRegex` with a signature similar to [what we have in .NET](https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.ismatch?view=net-9.0#system-text-regularexpressions-regex-ismatch(system-string-system-string-system-text-regularexpressions-regexoptions-system-timespan)): `public static bool IsMatch(string input, string pattern, System.Text.RegularExpressions.RegexOptions options)`

Contributor guide

Open the contributing guide

Research direction

No repository files or tests are identified; begin by locating the existing replace and contains functions and their tests. Compare their current signatures and behavior with the requested replaceRegex and matchesRegex functions. Done means both pattern-based operations are implemented and their behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.