There are indeed two matches, but they are not what you might think they are.
The following pattern
(Or in this case, more simply:
)
Captures zero or more of any character, immediately preceded by
test1, and immediately followed by either a
c or nothing - all as lazily as possible. Because the group can capture zero characters followed by nothing, it does so, and so the match starts and stops immediately after the
1 of the
test1s:
//echo -ga $regsubex(test1...ctest1...,/(test1)(.*?)c?/g,\1<\2>)
Returns
test1<>...ctest1<>...(Note that here I also capture the
test1s so that they won't be, er, "thrown away" in the final substituted string...)