You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
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
The text was updated successfully, but these errors were encountered:
split each input file on \n before doing the regex replace
This would make it more grep-like, though it would have different semantics than for example my text editor, where $ and ^ are done per-line, but I can still replace \n if I need to.
I was thinking just having users use \n instead of $ or ^, but unfortunately that breaks on the first/last line of a file, where there is no preceding/trailing \n.
This would make it more grep-like, though it would have different semantics than for example my text editor, where $ and ^ are done per-line, but I can still replace \n if I need to.
@pdewilde, could it be that your editor is in multiline mode by default? It doesn't look like we have the ability to make that happen in Go 😞 . Unless we resort to using https://pkg.go.dev/regexp/syntax#Prog which is a lower-level API to regexes that looks like dragons. But at first glance it does seem desirable to default to multiline mode.
We could wrap the user's regex in (?m:their_regex), but that seems gross. Maybe acceptably gross though.
TL;DR
As a template developer, I want
^
and$
to match beginning and end of line, because that's what I'm used to fromgrep
. 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:
Downside:
Implementation ideas:
\n
before doing the regex replaceDetailed design
No response
Alternatives considered
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: