When a find operation takes a long time, not because of the complexity of the expression, but because of the length of the string being searched, it would be valuable to have a callback.
Currently ICU regex has a "match" callback that can be set to be called periodically during the evaluation of a complex expression, to give the client the opportunity to cancel e.g. if backtracking takes exponential time.
It would be useful to have a second callback, what we might call a "progress" callback, that would be called as the internal position of the matcher advances.
The find() function would get along well with your proposal, however. The match engine proper is really determining whether the pattern matches the string at a specific starting position. find(), on the other hand, is searching for matches, has its own loop for that search, and does move consistently forward
<From Michael Grady>
We have the "find progress" callback hooked up and working. It works especially well in the failure case because MatchAt() reports back to find() which then repeatedly advances the index and retries.
Need proposal to icu-design
Proposal sent out to icu-design 6/6/10 "Proposal: Regex "find progress" callback for 4.5.1"
Branched sources in branches/mishonok/regex-callback
Merged changes from branch to trunk
Milestone 4.5.1 deleted