Given the following text:
defmodule MyModule do
app_env(:plans, :myapp, [:billing, :plans],
binding_order: [:config],
required: true,
type: :any
)
app_env(
:plans_with_min_amount_of_integrations,
:myapp,
[:billing, :plans_with_min_amount_of_integrations],
binding_order: [:config],
required: true,
type: :any
)
end
I'm trying to match with the following condition in mind:
myapp
string,- that is known to be located between
app_env
and:billing
strings.
To do this, I'm running:
rg --replace '$1' --multiline --multiline-dotall "app_env.*?(myapp).*?billing" test.txt
I expect the following output
2:myapp
10:myapp
But for some reason, I'm getting the following output:
2:myapp
8:myapp
Why? How do I change the regexp to return the correct lines, while retaining the conditions?
Note, that this example is simplified, and is a part of a larger code search effort of precisely looking & replacing the code, so simply running rg myapp
won't cut it in this case.