it may be helpful to mention that this is only affecting the first iteration of the g-option implementation:

Code:
//echo -a $regsubex(abcde, /./g, x)


produces "xbxxx".

we can further observe that the second match is only detected correctly when it doesn't immediately follow the first:

Code:
//echo -a $regex(abcdef, /abc|e|f/g) - $regex(abcdef, /abc|d|f/g)


produces "3 - 2".

it appears that the "offset advance by 1" measure added to the demo code to protect against infinite loops when \K is used in lookbehinds is being triggered for all cases in the first iteration of the loop.

pure speculation: the workaround for get_startchar() may involve a variable that doesn't get initialized before the loop, so its first use is bugged.


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde