1 19 20 package gnu.regexp; 21 22 class RETokenStart extends REToken { 23 private String newline; 25 RETokenStart(int subIndex, String newline) { 26 super(subIndex); 27 this.newline = newline; 28 } 29 30 boolean match(CharIndexed input, REMatch mymatch) { 31 34 if (newline != null) { 35 int len = newline.length(); 36 if (mymatch.offset >= len) { 37 boolean found = true; 38 char z; 39 int i = 0; char ch = input.charAt(mymatch.index - len); 41 do { 42 z = newline.charAt(i); 43 if (ch != z) { 44 found = false; 45 break; 46 } 47 ++i; 48 ch = input.charAt(mymatch.index - len + i); 49 } while (i < len); 50 51 if (found) return next(input, mymatch); 52 } 53 } 54 55 if ((mymatch.eflags & RE.REG_NOTBOL) > 0) return false; 57 58 if ((mymatch.eflags & RE.REG_ANCHORINDEX) > 0) 59 return (mymatch.anchor == mymatch.offset) ? 60 next(input, mymatch) : false; 61 else 62 return ((mymatch.index == 0) && (mymatch.offset == 0)) ? 63 next(input, mymatch) : false; 64 } 65 66 void dump(StringBuffer os) { 67 os.append('^'); 68 } 69 } 70 | Popular Tags |