In regex_replace action, consider doing line-by-line matching instead of entire file
- Linguagem predominante
- Go
- Estrelas
- 16
- Forks
- 4
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
### 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_
Guia de contribuição
Direção de pesquisa
Find the regex_replace action implementation in the codebase, likely under a cmd or actions directory. Understand how it currently processes files (likely reading entire content). The change involves splitting input by newline for line-by-line matching and potentially adding a new mode parameter. Look for existing tests for regex_replace to understand the expected behavior and add new test cases.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- go
- Domínio
- cli, tooling
- Tipo de issue
- Funcionalidade
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 45/100