Ah, good to know! In the end, I'm happy with (?!REG_MKT) - it's shorter and works reliably so far.The (POST_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).
Just tested this, No1 my current regex and No2 removed the .*? you mentioned: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
No1: (?siU)^(?|.*<curmktstatus>(?!REG_MKT).*<extendedMktQuote>.*<last>(.*)<\/last>.*?|.*?<last>(.*)<\/last>)
No2: (?siU)^(?|.*<curmktstatus>(?!REG_MKT).*<extendedMktQuote>.*<last>(.*)<\/last>|.*?<last>(.*)<\/last>)
Symption: No2 gives TWO matches (when curmktstatus=PRE_MKT or POST_MKT) - so it then matches both <last> prices. This works, if the first match is the correct one and in this case it probably is always the case, but I like it better if there's only one distinct match. You can surely explain the effect behind, I still cannot due this with any confidence without taking an hour of studying, probably. But I really like using regex101.com, this is really a big help.
Summary: I keep on going with these 3 working expressions. So far, so good - let's see what happens over the weekend, when all markets are closed. Well, just checked, NASDAQ just closed and the expressions are still doing their job correctly! I'm now 98% confident that I found a working solution, thanks to your strong guidance. The only open issue could be other exchanges around the globe where CNBC might deliver deviating xml potentially breaking these expressions. Anybody reading this and observing issues, please drop us a note.
Code:
; Price e.g. [mIndex1_Price]RegExp=(?siU)^(?|.*<curmktstatus>(?!REG_MKT).*<extendedMktQuote>.*<last>(.*)<\/last>.*?|.*?<last>(.*)<\/last>); Price change e.g. [mIndex1_UpDown]RegExp=(?siU)^(?|.*<curmktstatus>(?!REG_MKT).*<extendedMktQuote>.*<change>(.*)<\/change>.*?|.*<change>(.*)<\/change>); Price change% e.g. [mIndex1_ChangePer]RegExp=(?siU)^(?|.*<curmktstatus>(?!REG_MKT).*<extendedMktQuote>.*<change_pct>(.*)<\/change_pct>.*?|.*<change_pct>(.*)<\/change_pct>)



Statistics: Posted by emp00 — Yesterday, 7:07 pm