WTF^1. It's quite simple, if you think about it: inverting the global flag also inverts the "meaning" of the local ones, even though the same symbols are used locally. Real life example: if you talk about an overall sunny day and you say that for one hour the weather was different than for the rest of the day, it is implied that for that hour the weather was rainy; on the other hand, if you talk about an overall rainy day and you say the exact same thing, it is implied that for that hour the weather was sunny, so the complete opposite compared to the former. See how the global context completely changes the meaning of the local one? Same with regex.
WTF^2. The (REG_MKT|PRE_MKT) didn't work because it was not followed by the <\/curmktstatus> ending tag (or even < would have been enough), and the regex didn't know where to stop with the match given that .* is volatile (i.e. it lacked some fixed place where to "anchor" the pattern at its end). Also, the correct way would have been (?:REG_MKT|PRE_MKT) aka making it a NON capture group, otherwise it would have messed the StringIndex or the \N capture references and be returned as a capture instead of the desired <last> further down the pattern. The negative lookahead works precisely because it's "negative" and chooses that branch as soon as the first character after the preceding > is not R (for performance reasons, it never bothers with the following EG_MKT since the pattern was already matched).
WTF^3. Yeah, difficulties and obstacles are normal, but naturally the satisfaction is greater if you overcome them on your own, plus it helps you the next time you have a similar situation. All children fall and cry before learning to walk, there's no other way of learning that hitting your head against the wall and see who wins, lol. Anyway, I'm glad you gave it a try and managed to get something out of it, that's the spirit! The next times you'll figure out things in a shorter and shorter time. Didn't test it now and it will remain to be seen if the pattern is indeed what you really need, but just a little observation: I don't think the .*? before the | are necessary, since, like I said earlier, there isn't a fixed character or position in the string where to "anchor" the end of the .*? in order for the greedy match to have a functional purpose. Regex is almost always just an alternation of "fixed" and "variable" points, and usually the latter require the former to enclose them - if you say "from Paris to the end of the world" the result is undefined since there's no end of the world unless you're a flat earther, but if you say "from Paris to London" then the result is precise and you can work with it.
Keep up the attitude you showed when adjusting the pattern - you're on the right path! If it's too much, take a break and relax and come back stronger and with better ideas - you don't have to exhaust yourself every time!
![Thumbs Up :thumbup:](./images/smilies/ay.gif)
![Great :great:](./images/smilies/dn.gif)