int i; for (i=0; i<10; i++) { if (string.substr(i,1) == something) { i += some_other_function(); retry; } else if (string.substr(i,1) == something_else) { i += some_other_function2(); retry; } // Otherwise, simply execute the "i++" and re-test }