2 // This software is now distributed according to
3 // the Lesser Gnu Public License. Please see
4 // http://www.gnu.org/copyleft/lesser.txt for
8 package com.stevesoft.pat;
10 import java.util.Hashtable;
13 * Provides the ability to match a backreference from within a Pattern.
15 class BackMatch extends Pattern
24 public String toString()
26 return "\\" + (id) + nextString();
29 public int matchInternal(int pos, Pthings p)
32 int i2 = p.marks[id + p.nMarks];
34 if (i1 < 0 || imax < 0 || pos + imax > p.src.length())
38 int ns = p.src.length() - pos;
43 for (int i = 0; i < ns; i++)
45 if (p.src.charAt(i + i1) != p.src.charAt(pos + i))
50 return nextMatch(pos + imax, p);
53 Pattern clone1(Hashtable h)
55 return new BackMatch(id);