Just seemed that at the point when the code sets mySmatch[curIndex].matched to true, then it could "tuck away" that index in an accessible variable .... but apparently not.
No it has to maintain a stack of all past values, in order to backtrack out of a match.
Any suggestions about alternative on how to best accomplish the search for Bible verse references? I'd have to think the participants in this thread would have some deep insights on the best way to proceed.
This is a deep insight free zone :-) If you just want the first index to have matched then simply a linear search is as good as anything: int lowest_match = 1; for(; lowest_match < mymatch.size(); ++lowest_match) if(mymatch[lowest_match].matched) break; which assumes that your regex is along the lines of: (a)|(b)|(c)|... If that turns out too slow, then you might then have to collect together common prefixes for some of the expressions into single alternatives, but I'm not knowledgeable on bible references. John.