textsearch.cxx (cdce7373) textsearch.cxx (16b8677b)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 740 unchanged lines hidden (view full) ---

749
750 if( endPos > searchStr.getLength())
751 endPos = searchStr.getLength();
752
753 // use the ICU RegexMatcher to find the matches
754 UErrorCode nIcuErr = U_ZERO_ERROR;
755 const IcuUniString aSearchTargetStr( searchStr.getStr(), endPos);
756 pRegexMatcher->reset( aSearchTargetStr);
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 740 unchanged lines hidden (view full) ---

749
750 if( endPos > searchStr.getLength())
751 endPos = searchStr.getLength();
752
753 // use the ICU RegexMatcher to find the matches
754 UErrorCode nIcuErr = U_ZERO_ERROR;
755 const IcuUniString aSearchTargetStr( searchStr.getStr(), endPos);
756 pRegexMatcher->reset( aSearchTargetStr);
757 if( !pRegexMatcher->find( startPos, nIcuErr))
758 return aRet;
757 // search until there is a valid match
758 for(;;)
759 {
760 if( !pRegexMatcher->find( startPos, nIcuErr))
761 return aRet;
759
762
763 // #i118887# ignore zero-length matches e.g. "a*" in "bc"
764 int nStartOfs = pRegexMatcher->start( nIcuErr);
765 int nEndOfs = pRegexMatcher->end( nIcuErr);
766 if( nStartOfs < nEndOfs)
767 break;
768 // try at next position if there was a zero-length match
769 if( ++startPos >= endPos)
770 return aRet;
771 }
772
773 // extract the result of the search
760 const int nGroupCount = pRegexMatcher->groupCount();
761 aRet.subRegExpressions = nGroupCount + 1;
762 aRet.startOffset.realloc( aRet.subRegExpressions);
763 aRet.endOffset.realloc( aRet.subRegExpressions);
764 aRet.startOffset[0] = pRegexMatcher->start( nIcuErr);
765 aRet.endOffset[0] = pRegexMatcher->end( nIcuErr);
766 for( int i = 1; i <= nGroupCount; ++i) {
767 aRet.startOffset[i] = pRegexMatcher->start( i, nIcuErr);

--- 232 unchanged lines hidden ---
774 const int nGroupCount = pRegexMatcher->groupCount();
775 aRet.subRegExpressions = nGroupCount + 1;
776 aRet.startOffset.realloc( aRet.subRegExpressions);
777 aRet.endOffset.realloc( aRet.subRegExpressions);
778 aRet.startOffset[0] = pRegexMatcher->start( nIcuErr);
779 aRet.endOffset[0] = pRegexMatcher->end( nIcuErr);
780 for( int i = 1; i <= nGroupCount; ++i) {
781 aRet.startOffset[i] = pRegexMatcher->start( i, nIcuErr);

--- 232 unchanged lines hidden ---