internal override boolean match(Matcher matcher, int i, CharSequence seq)
 {
     int savedTo = matcher.to;
     boolean conditionMatched = false;
     // Relax transparent region boundaries for lookahead
     if (matcher.transparentBounds)
         matcher.to = matcher.getTextLength();
     try {
         if (i < matcher.to) {
             conditionMatched = !cond.match(matcher, i, seq);
         } else {
             // If a negative lookahead succeeds then more input
             // could cause it to fail!
             matcher._requireEnd = true;
             conditionMatched = !cond.match(matcher, i, seq);
         }
     } finally {
         // Reinstate region boundaries
         matcher.to = savedTo;
     }
     return conditionMatched && next.match(matcher, i, seq);
 }
 int check(Matcher matcher, int i, CharSequence seq) {
     int ch;
     boolean left = false;
     int startIndex = matcher.from;
     int endIndex = matcher.to;
     if (matcher.transparentBounds) {
         startIndex = 0;
         endIndex = matcher.getTextLength();
     }
     if (i > startIndex) {
         ch = Character.codePointBefore(seq, i);
         left = (isWord(ch) ||
             ((Character.getType(ch) == Character.NON_SPACING_MARK)
              && hasBaseCharacter(matcher, i-1, seq)));
     }
     boolean right = false;
     if (i < endIndex) {
         ch = Character.codePointAt(seq, i);
         right = (isWord(ch) ||
             ((Character.getType(ch) == Character.NON_SPACING_MARK)
              && hasBaseCharacter(matcher, i, seq)));
     } else {
         // Tried to access char past the end
         matcher._hitEnd = true;
         // The addition of another char could wreck a boundary
         matcher._requireEnd = true;
     }
     return ((left ^ right) ? (right ? LEFT : RIGHT) : NONE);
 }
 internal override boolean match(Matcher matcher, int i, CharSequence seq)
 {
     int savedTo = matcher.to;
     boolean conditionMatched = false;
     // Relax transparent region boundaries for lookahead
     if (matcher.transparentBounds)
         matcher.to = matcher.getTextLength();
     try {
         conditionMatched = cond.match(matcher, i, seq);
     } finally {
         // Reinstate region boundaries
         matcher.to = savedTo;
     }
     return conditionMatched && next.match(matcher, i, seq);
 }
 internal override boolean match(Matcher matcher, int i, CharSequence seq)
 {
     int endIndex = (matcher.anchoringBounds) ?
         matcher.to : matcher.getTextLength();
     if (i < endIndex) {
         char ch = seq.charAt(i);
         if (ch == '\n') {
             // If not multiline, then only possible to
             // match at very end or one before end
             if (multiline == false && i != endIndex - 1)
                 return false;
             // If multiline return next.match without setting
             // matcher.hitEnd
             if (multiline)
                 return next.match(matcher, i, seq);
         } else {
             return false;
         }
     }
     // Matching because at the end or 1 before the end;
     // more input could change this so set hitEnd
     matcher._hitEnd = true;
     // If a $ matches because of end of input, then more input
     // could cause it to fail!
     matcher._requireEnd = true;
     return next.match(matcher, i, seq);
 }
 internal override boolean match(Matcher matcher, int i, CharSequence seq)
 {
     int endIndex = (matcher.anchoringBounds) ?
         matcher.to : matcher.getTextLength();
     if (!multiline) {
         if (i < endIndex - 2)
             return false;
         if (i == endIndex - 2) {
             char ch = seq.charAt(i);
             if (ch != '\r')
                 return false;
             ch = seq.charAt(i + 1);
             if (ch != '\n')
                 return false;
         }
     }
     // Matches before any line terminator; also matches at the
     // end of input
     // Before line terminator:
     // If multiline, we match here no matter what
     // If not multiline, fall through so that the end
     // is marked as hit; this must be a /r/n or a /n
     // at the very end so the end was hit; more input
     // could make this not match here
     if (i < endIndex) {
         char ch = seq.charAt(i);
          if (ch == '\n') {
              // No match between \r\n
              if (i > 0 && seq.charAt(i-1) == '\r')
                  return false;
              if (multiline)
                  return next.match(matcher, i, seq);
          } else if (ch == '\r' || ch == '\u0085' ||
                     (ch|1) == '\u2029') {
              if (multiline)
                  return next.match(matcher, i, seq);
          } else { // No line terminator, no match
              return false;
          }
     }
     // Matched at current end so hit end
     matcher._hitEnd = true;
     // If a $ matches because of end of input, then more input
     // could cause it to fail!
     matcher._requireEnd = true;
     return next.match(matcher, i, seq);
 }
 internal override boolean match(Matcher matcher, int i, CharSequence seq)
 {
     int startIndex = matcher.from;
     int endIndex = matcher.to;
     if (!matcher.anchoringBounds) {
         startIndex = 0;
         endIndex = matcher.getTextLength();
     }
     // Perl does not match ^ at end of input even after newline
     if (i == endIndex) {
         matcher._hitEnd = true;
         return false;
     }
     if (i > startIndex) {
         char ch = seq.charAt(i-1);
         if (ch != '\n') {
             return false;
         }
     }
     return next.match(matcher, i, seq);
 }
 internal override boolean match(Matcher matcher, int i, CharSequence seq)
 {
     int endIndex = (matcher.anchoringBounds) ?
         matcher.to : matcher.getTextLength();
     if (i == endIndex) {
         matcher._hitEnd = true;
         return next.match(matcher, i, seq);
     }
     return false;
 }