Skip to content

Support replacements capture groups #702

@Magic-Mayo

Description

@Magic-Mayo

Is your feature request related to a problem? Please describe.
Currently, Replacement only allows you to replace with a hardcoded string or with ReplaceData when processing replacements. I'd like to use the shortest possible regex since I'm covering multiple lines of text to find what I'm looking for.

Specifically, I'm trying to update versions of dependencies in a helm chart so I can't just do something like version: .* as there will be multiple lines in the Chart.yaml that have that. I need to get the specific list item and update the version so my regex would look something like this when updating a single dependency:

(- name: chartName.+?version): \d+\.\d+\.\d+

I'd like to use the capture group to put whatever string I found back in place. This helps with not having to format each of those files very specifically and ensures no mistakes are made. It also keeps us from having to do a bunch tedious formatting as well as making sure we don't have to follow a specific format in the future.

Describe the solution you'd like
Supporting regex capture groups

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
I've tested out some changes and can post a PR if you think the feature is worthwhile

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions