示例#1
0
        /// <summary>
        /// The find() method matches the pattern against the character sequence
        /// beginning at the character after the last match or at the beginning of
        /// the sequence if called immediately after reset(). The method returns true
        /// if and only if a match is found.
        /// </summary>
        ///
        /// <returns>A boolean indicating if the pattern was matched.</returns>
        public bool Find()
        {
            int length = str0.Length;

            if (!HasTransparentBounds())
            {
                length = rightBound;
            }
            if (matchResult.startIndex >= 0 &&
                matchResult.Mode() == Matcher.MODE_FIND)
            {
                matchResult.startIndex = matchResult.End();
                if (matchResult.End() == matchResult.Start())
                {
                    matchResult.startIndex++;
                }

                return((matchResult.startIndex <= length) ? Find(matchResult.startIndex)
                                                : false);
            }
            else
            {
                return(Find(leftBound));
            }
        }
示例#2
0
 public override int Matches(int stringIndex, String testString,
                             MatchResultImpl matchResult)
 {
     if (matchResult.Mode() == Matcher.MODE_FIND ||
         stringIndex == matchResult.GetRightBound())
     {
         matchResult.SetValid();
         matchResult.SetEnd(0, stringIndex);
         return(stringIndex);
     }
     return(-1);
 }