Ok, step 1:
Step 2 (ignoring the parenthesis):
.*: match any character 0 or more times
? : but don't be greedy. Use the minimal amount of characters possible to make the match.
\+: match a +
.*: match any character 0 or more times
? : but don't be greedy. Use the minimal amount of characters possible to make the match.
In other words try an match any pattern of text up to and including a second + (but no more than that)
OK, now for the parenthesis. We use these to group together part of the match and to be able to refer to that partial match later. Each bracketed section gets a name: $1, $2, $3, $4 ... which we can refer to in our replace method
So, assuming mattach is found, in this example $1 refers to the match up to but not including the second +, and $2 would refer to the + itself
Then in the replace method we replace the matched string (everything up to and including the second +) with $1 (everything up to but not including the second +) followed by -. ANything subsequent to the second + remains untouched
This has the required effect of replacing the second + with -