abcxyz / abcxyz/abc

In regex_replace action, consider doing line-by-line matching instead of entire file

未关闭
#120 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement
主要语言
Go
星标
16
派生
4
PR 合并指标
30 天内没有已合并 PR

描述

### TL;DR

As a template developer, I want `^` and `$` to match beginning and end of line, because that's what I'm used to from `grep`. As a template developer I'm probably not aware of how to do RE2 multiline regexes to manually enable this behavior using `(?m:my_regex)`.

cc @sethvargo @pdewilde @verbanicm who have been involved in related conversations.

Upside:
- Users don't have to understand RE2 multiline syntax and semantics to match beginning/end of line
Downside:
- If users want to match a string that spans multiple lines within a file, we have to give them a special mode.

Implementation ideas:
- split each input file on `\n` before doing the regex replace
- add a new mode for users that want to do a search-and-replace that spans multiple lines. Something like:
```
action: `regex_replace`
params:
paths: ['my.txt']
replacements:
mode: 'file_at_a_time' # <---- here we need a new mode
regex: |
my
regex
with
newlines
replace_with: 'whatever'
```

### Detailed design

_No response_

### Alternatives considered

_No response_

### Additional information

_No response_

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。