Let's assume the following text
a=1
b=2
x=1
---------
a=1
b=3
c=3
x=2
---------
a=2
b=5
x=3
... and so on, many blocks starting with a=, ending with x= and something in between
I would like to replace the x value with 0 for all blocks where a=1. For this, I search for the following
^(a=1$.*?x=).*$
and replace it with
\10
The problem is, that the first occurence already extends from the first a=1 to the last x=3. It does not stop at the first occurence of x (i.e. x=1)
How can I make it select only from the first a to the x that goes along with this a (i.e. only the first 3 lines, then the 4 lines of the next block, and so on)?