/** */ public final boolean isCaptured(int id) { return bounds(id) != null; }
/** */ public final int length(int id) { MemReg mr = bounds(id); if(mr != null) return mr.out - mr.in; return 0; }
/** */ public final boolean isCaptured(int id) { return bounds(id) != null; }
/** */ public final int length(int id) { MemReg mr = bounds(id); if(mr != null) return mr.out - mr.in; return 0; }
/** * Returns the offset after the last character of the subsequence * captured by the given group during this match. * <br> * Capturing groups are indexed from left * to right, starting at one. Group zero denotes the entire pattern, so * the expression <i>m.</i><tt>end(0)</tt> is equivalent to * <i>m.</i><tt>end()</tt>. * * @param id * The index of a capturing group in this matcher's pattern * * @return The offset after the last character captured by the group, * or <tt>-1</tt> if the match was successful * but the group itself did not match anything */ public final int end(int id) { MemReg b = bounds(id); if(b == null) return -1; return b.out - offset; }
/** * Returns the start index of the subsequence captured by the given group * during this match. * <br> * Capturing groups are indexed from left * to right, starting at one. Group zero denotes the entire pattern, so * the expression <i>m.</i><tt>start(0)</tt> is equivalent to * <i>m.</i><tt>start()</tt>. * @param id * The index of a capturing group in this matcher's pattern * @return The index of the first character captured by the group, * or <tt>-1</tt> if the match was successful but the group * itself did not match anything */ public final int start(int id) { MemReg b = bounds(id); if(b == null) return -1; return b.in - offset; }
/** * Returns the start index of the subsequence captured by the given group * during this match. * <br> * Capturing groups are indexed from left * to right, starting at one. Group zero denotes the entire pattern, so * the expression <i>m.</i><tt>start(0)</tt> is equivalent to * <i>m.</i><tt>start()</tt>. * @param id * The index of a capturing group in this matcher's pattern * @return The index of the first character captured by the group, * or <tt>-1</tt> if the match was successful but the group * itself did not match anything */ public final int start(int id) { MemReg b = bounds(id); if(b == null) return -1; return b.in - offset; }
/** * Returns the offset after the last character of the subsequence * captured by the given group during this match. * <br> * Capturing groups are indexed from left * to right, starting at one. Group zero denotes the entire pattern, so * the expression <i>m.</i><tt>end(0)</tt> is equivalent to * <i>m.</i><tt>end()</tt>. * * @param id * The index of a capturing group in this matcher's pattern * * @return The offset after the last character captured by the group, * or <tt>-1</tt> if the match was successful * but the group itself did not match anything */ public final int end(int id) { MemReg b = bounds(id); if(b == null) return -1; return b.out - offset; }
public char charAt(int i, int groupId) { MemReg mr = bounds(groupId); if (mr == null) throw new IllegalStateException("group #" + groupId + " is not assigned"); int in = mr.in; if (i < 0 || i > (mr.out - in)) throw new StringIndexOutOfBoundsException("" + i); return data[in + i]; }
public char charAt(int i, int groupId) { MemReg mr = bounds(groupId); if (mr == null) throw new IllegalStateException("group #" + groupId + " is not assigned"); int in = mr.in; if (i < 0 || i > (mr.out - in)) throw new StringIndexOutOfBoundsException("" + i); return data[in + i]; }
/** */ public ArrayList<String> groupv() { MemReg[] memregs = this.memregs; ArrayList<String> v = new ArrayList<String>(); MemReg mr; for (int i = 0; i < memregs.length; i++) { mr = bounds(i); if (mr == null) { v.add("empty"); continue; } String s = getString(mr.in, mr.out); v.add(s); } return v; }
/** */ public ArrayList<String> groupv() { MemReg[] memregs = this.memregs; ArrayList<String> v = new ArrayList<String>(); MemReg mr; for (int i = 0; i < memregs.length; i++) { mr = bounds(i); if (mr == null) { v.add("empty"); continue; } String s = getString(mr.in, mr.out); v.add(s); } return v; }
/** * This method allows to efficiently pass data between matchers. * Note that a matcher may pass data to itself:<pre> * Matcher m=new Pattern("\\w+").matcher(myString); * if(m.find())m.setTarget(m,m.SUFFIX); //forget all that is not a suffix * </pre> * Resets current search position to zero. * * @param m - a matcher that is a source of data * @param groupId - which group to take data from * @see Matcher#setTarget(java.lang.CharSequence) * @see Matcher#setTarget(java.lang.CharSequence, int, int) * @see Matcher#setTarget(char[], int, int) * @see Matcher#setTarget(java.io.Reader, int) */ public final void setTarget(Matcher m, int groupId) { MemReg mr = m.bounds(groupId); if (mr == null) throw new IllegalArgumentException("group #" + groupId + " is not assigned"); data = m.data; offset = mr.in; end = mr.out; cache = m.cache; cacheLength = m.cacheLength; cacheOffset = m.cacheOffset; if (m != this) { shared = true; m.shared = true; } init(); }
MemReg mr = bounds(group); if (mr == null) return null; return getString(mr.in, mr.out);
/** * This method allows to efficiently pass data between matchers. * Note that a matcher may pass data to itself:<pre> * Matcher m=new Pattern("\\w+").matcher(myString); * if(m.find())m.setTarget(m,m.SUFFIX); //forget all that is not a suffix * </pre> * Resets current search position to zero. * * @param m - a matcher that is a source of data * @param groupId - which group to take data from * @see Matcher#setTarget(java.lang.CharSequence) * @see Matcher#setTarget(java.lang.CharSequence, int, int) * @see Matcher#setTarget(char[], int, int) * @see Matcher#setTarget(java.io.Reader, int) */ public final void setTarget(Matcher m, int groupId) { MemReg mr = m.bounds(groupId); if (mr == null) throw new IllegalArgumentException("group #" + groupId + " is not assigned"); data = m.data; offset = mr.in; end = mr.out; cache = m.cache; cacheLength = m.cacheLength; cacheOffset = m.cacheOffset; if (m != this) { shared = true; m.shared = true; } init(); }
MemReg mr = bounds(group); if (mr == null) return null; return getString(mr.in, mr.out);
public boolean getGroup(int group, StringBuilder sb, int modes) { MemReg mr = bounds(group); if (mr == null) return false; int in = mr.in;
public boolean getGroup(int group, StringBuilder sb, int modes) { MemReg mr = bounds(group); if (mr == null) return false; int in = mr.in;
public boolean getGroup(int group, TextBuffer tb, int modes) { MemReg mr = bounds(group); if (mr == null) return false; int in = mr.in;
public boolean getGroup(int group, TextBuffer tb, int modes) { MemReg mr = bounds(group); if (mr == null) return false; int in = mr.in;