My goal is to replace all instances of a trailing - to a trailing + within tag brackets. Lets assume the line to be replaced looks like this:
<h> aa- aa- </h> <h> ba- ba- </h>
and should afterwards look like
<h> aa+ aa+ </h> <h> ba+ ba+ </h>
First I tried this expression:
s/<h>(.*?)-(.*?)<\/h>/<h>$1+$2<\/h>/g;
which yielded this output:
<h> aa+ aa- </h> <h> ba+ ba- </h>
The g option does lead to more than one substitution per line, but only for the first instance per tag bracket (and only if both round brackets contain the question mark).
To narrow down the problem, I then tried to to achieve substitution disregarding the tags. The expression
s/(.*?)-(.*?)/$1+$2/g;
leads indeed to the desired result
<h> aa+ aa+ </h> <h> ba+ ba+ </h>
This will substitute outside of the tag brackets as well, of course.
So what is the problem with my first expression, and how can I achieve my goal of complete substitution within tag brackets?