Okay, so here's the problem:
Code:
desc: String Matching Scenario
@init
#string = "StartMiddleEnd";
match("%0sStart%s", #string, #beforeStart, #middleEnd);
// matches: #beforeStart = "" and #middleEnd = "MiddleEnd"
match("Start%0sMiddle%s", #string, #betweenStartAndMiddle, #end);
// matches: #betweenStartAndMiddle = "" and #end = "End"
match("%sEnd%0s", #string, #startMiddle, #pastEnd);
// doesn't match (but should): no string values assigned
Basically, it seems that
%0s at the end of a match string 'needle' won't match a zero-length string in the 'haystack'. My guess is that the matching logic terminates its search efforts prematurely because the end of the string is reached.
As you can see, elsewhere in the string it works as specified.
My workaround is a backup case in the match chain (without the %0s at the end) that forces a "" for #pastEnd. However, this clutters the code unnecessarily and adds another computation into the works, as well as being rather confusing behaviour to debug.
Any chance of fixing this?