Class Pattern

    • Constructor Detail

      • Pattern

        public Pattern()
    • Method Detail

      • match

        public abstract int match​(java.lang.CharSequence src,
                                  int begin,
                                  int end)
        Matches character range against the pattern. The length of the range is end - begin.
        Parameters:
        src - the source string.
        begin - the beginning index in the sequence.
        end - the end index of the source string (exclusive). NOTE: the range is [begin, end).
        Returns:
        the number of characters matched. MISMATCH otherwise.
      • next

        public final Pattern next​(Pattern next)
        Returns a Pattern object that sequentially matches the character range against this and then next. If both succeeds, the entire match length is returned.
        Parameters:
        next - the next pattern to match.
        Returns:
        the new Pattern object.
      • optional

        public final Pattern optional()
        Returns a Pattern object that matches with 0 length even if this mismatches.
      • many

        public final Pattern many()
        Returns a Pattern object that matches this pattern for 0 or more times. The total match length is returned.
      • many

        @Deprecated
        public final Pattern many​(int min)
        Deprecated.
        Use atLeast(int) instead.
        Returns Pattern object that matches this pattern for at least min times. The total match length is returned.
        Parameters:
        min - the minimal number of times to match.
        Returns:
        the new Pattern object.
      • atLeast

        public final Pattern atLeast​(int min)
        Returns Pattern object that matches this pattern for at least min times. The total match length is returned.
        Parameters:
        min - the minimal number of times to match.
        Returns:
        the new Pattern object.
        Since:
        2.2
      • many1

        public final Pattern many1()
        Returns a Pattern object that matches this pattern for 1 or more times. The total match length is returned.
      • some

        @Deprecated
        public final Pattern some​(int max)
        Deprecated.
        Use atMost(int) instead.
        Returns Pattern object that matches this pattern for up to max times. The total match length is returned.
        Parameters:
        max - the maximal number of times to match.
        Returns:
        the new Pattern object.
      • atMost

        public final Pattern atMost​(int max)
        Returns Pattern object that matches this pattern for up to max times. The total match length is returned.
        Parameters:
        max - the maximal number of times to match.
        Returns:
        the new Pattern object.
        Since:
        2.2
      • some

        @Deprecated
        public final Pattern some​(int min,
                                  int max)
        Deprecated.
        Use times(int, int) instead.
        Returns Pattern object that matches this pattern for at least min times and up to max times. The total match length is returned.
        Parameters:
        min - the minimal number of times to match.
        max - the maximal number of times to match.
        Returns:
        the new Pattern object.
      • times

        public final Pattern times​(int min,
                                   int max)
        Returns Pattern object that matches this pattern for at least min times and up to max times. The total match length is returned.
        Parameters:
        min - the minimal number of times to match.
        max - the maximal number of times to match.
        Returns:
        the new Pattern object.
        Since:
        2.2
      • not

        public final Pattern not()
        Returns a Pattern object that only matches if this pattern mismatches, 0 is returned otherwise.
      • peek

        public final Pattern peek()
        Returns Pattern object that matches with match length 0 if this Pattern object matches.
      • ifelse

        public final Pattern ifelse​(Pattern consequence,
                                    Pattern alternative)
        Returns Pattern object that, if this pattern matches, matches the remaining input against consequence pattern, or otherwise matches against alternative pattern.
      • repeat

        @Deprecated
        public final Pattern repeat​(int n)
        Deprecated.
        Use times(int) instead.
        Returns Pattern object that matches the input against this pattern for n times.
      • times

        public final Pattern times​(int n)
        Returns Pattern object that matches the input against this pattern for n times.
        Since:
        2.2
      • or

        public final Pattern or​(Pattern p2)
        Returns Pattern object that matches if either this or p2 matches.
      • times

        private static Pattern times​(Pattern pp,
                                     int min,
                                     int max)