bool t4p::FinderClass::FindNextRegularExpression(const UnicodeString& text, int32_t start) { if (U_SUCCESS(PatternErrorCode) && Pattern != NULL) { UnicodeString findText(text); if (start > 0 && start < text.length()) { findText.setTo(text, start); } else if (start > 0) { findText = UNICODE_STRING_SIMPLE(""); } int32_t foundPos = 0, length = 0, endPos = 0; UErrorCode error = U_ZERO_ERROR; RegexMatcher* matcher = Pattern->matcher(findText, error); if (U_SUCCESS(error) && matcher) { if (matcher->find()) { foundPos = matcher->start(error); endPos = matcher->end(error); if (U_SUCCESS(error) && U_SUCCESS(error)) { IsFound = true; length = endPos - foundPos; // end is the index after the match // if search was started from the middle of a string, // need to correct the found position LastPosition = start > 0 ? foundPos + start : foundPos; LastLength = length; } } delete matcher; } } return IsFound; }