I'm using wrappers from Byte Comb (http://bytecomb.com/regular-expressions-in-vba/). They seem to be working very well. I need help formulating robust patterns.
I experience unexpected results when combining lookahead "(?=)" with or "|".
Input Text String Pattern RxMatch
----------------- ------- -------
iraq q(?!u) q
quit q(?!u) 0
iraq q(?=u) 0
quit q(?=u) q
sta.23.5 .1 words 67.89 ch \d+\.?\d*|\.\d+(?=\s*ch) 23.5
sta.23.5 .1 words 67.89 ch (\d+\.?\d*)|(\.\d+)(?=\s*ch) 23.5
sta.23.5 .1 words 67.89 ch \d+\.?\d*(?=\s*ch) 67.89
sta.23.5 .1 words 67.89 ch \d+\.?\d*(?=\s*ch)|\.\d+(?=\s*ch) 67.89
sta.23.5 .1 words .89 ch \d+\.?\d*|\.\d+(?=\s*ch) 23.5
sta.23.5 .1 words .89 ch (\d+\.?\d*)|(\.\d+)(?=\s*ch) 23.5
sta.23.5 .1 words .89 ch \d+\.?\d*(?=\s*ch) 89
sta.23.5 .1 words .89 ch \d+\.?\d*(?=\s*ch)|\.\d+(?=\s*ch) .89
"iraq" and "quit" work as expected. For the next set of input text strings, I hope to extract "67.89", and for the third, ".89". Initially, I formulated \d+.?\d*|.\d+ for floating decimal number to cover both situations. Adding parenthesis did not help. Removing the or helped for 67.89. Finally I found a working solution. But is there something better? Can you help me understand order of precedence? If possible, I'd like to keep the two parts of the or together.
Thanks, Not-a-programmer!