- startIndex = text.indexOf(exprStartDispMath);
- // We try to avoid infinite loops...
- static size_t max_loop = 1000;
- for (size_t i = 0; i != max_loop; ++i) {
- int endIndex = text.indexOf(exprEndDispMath, startIndex);
+ startIndex = exprStartDispMath.indexIn(text);
+ while (startIndex >= 0) {
+ int endIndex = exprEndDispMath.indexIn(text, startIndex);