So I tested your code, and it doesn't do for me what you say it does for you:
You're right, there's an
obvious bug. I am
really surprised that it had not popped out before (I mean, because I make a relatively intense use of it).
In the meantime I have slightly changed my mind about the "format" of input strings in a way that will add to functionality without requiring additional coding efforts, nay, probably making the code even lighter...
I'll post an updated version ASAP, but not now. I must go to study!