📄 perl5util.java
字号:
} /** * Splits input in the default Perl manner, splitting on all whitespace. * This method is identical to calling: * <blockquote><pre> * split("/\\s+/", input); * </pre></blockquote> * @deprecated Use * {@link #split(Collection results, String input)} instead. */ public synchronized Vector split(String input) throws MalformedPerl5PatternException { return split("/\\s+/", input); } // // MatchResult interface methods. // /** * Returns the length of the last match found. * <p> * @return The length of the last match found. */ public synchronized int length() { return __lastMatch.length(); } /** * @return The number of groups contained in the last match found. * This number includes the 0th group. In other words, the * result refers to the number of parenthesized subgroups plus * the entire match itself. */ public synchronized int groups() { return __lastMatch.groups(); } /** * Returns the contents of the parenthesized subgroups of the last match * found according to the behavior dictated by the MatchResult interface. * <p> * @param group The pattern subgroup to return. * @return A string containing the indicated pattern subgroup. Group * 0 always refers to the entire match. If a group was never * matched, it returns null. This is not to be confused with * a group matching the null string, which will return a String * of length 0. */ public synchronized String group(int group) { return __lastMatch.group(group); } /** * Returns the begin offset of the subgroup of the last match found * relative the beginning of the match. * <p> * @param group The pattern subgroup. * @return The offset into group 0 of the first token in the indicated * pattern subgroup. If a group was never matched or does * not exist, returns -1. Be aware that a group that matches * the null string at the end of a match will have an offset * equal to the length of the string, so you shouldn't blindly * use the offset to index an array or String. */ public synchronized int begin(int group) { return __lastMatch.begin(group); } /** * Returns the end offset of the subgroup of the last match found * relative the beginning of the match. * <p> * @param group The pattern subgroup. * @return Returns one plus the offset into group 0 of the last token in * the indicated pattern subgroup. If a group was never matched * or does not exist, returns -1. A group matching the null * string will return its start offset. */ public synchronized int end(int group) { return __lastMatch.end(group); } /** * Returns an offset marking the beginning of the last pattern match * found relative to the beginning of the input from which the match * was extracted. * <p> * @param group The pattern subgroup. * @return The offset of the first token in the indicated * pattern subgroup. If a group was never matched or does * not exist, returns -1. */ public synchronized int beginOffset(int group) { return __lastMatch.beginOffset(group); } /** * Returns an offset marking the end of the last pattern match found * relative to the beginning of the input from which the match was * extracted. * <p> * @param group The pattern subgroup. * @return Returns one plus the offset of the last token in * the indicated pattern subgroup. If a group was never matched * or does not exist, returns -1. A group matching the null * string will return its start offset. */ public synchronized int endOffset(int group) { return __lastMatch.endOffset(group); } /** * Returns the same as group(0). * <p> * @return A string containing the entire match. */ public synchronized String toString() { if(__lastMatch == null) return null; return __lastMatch.toString(); } /** * Returns the part of the input preceding the last match found. * <p> * @return The part of the input following the last match found. */ public synchronized String preMatch() { int begin; if(__originalInput == null) return __nullString; begin = __lastMatch.beginOffset(0); if(begin <= 0) return __nullString; if(__originalInput instanceof char[]) { char[] input; input = (char[])__originalInput; // Just in case we make sure begin offset is in bounds. It should // be but we're paranoid. if(begin > input.length) begin = input.length; return new String(input, __inputBeginOffset, begin); } else if(__originalInput instanceof String) { String input; input = (String)__originalInput; // Just in case we make sure begin offset is in bounds. It should // be but we're paranoid. if(begin > input.length()) begin = input.length(); return input.substring(__inputBeginOffset, begin); } return __nullString; } /** * Returns the part of the input following the last match found. * <p> * @return The part of the input following the last match found. */ public synchronized String postMatch() { int end; if(__originalInput == null) return __nullString; end = __lastMatch.endOffset(0); if(end < 0) return __nullString; if(__originalInput instanceof char[]) { char[] input; input = (char[])__originalInput; // Just in case we make sure begin offset is in bounds. It should // be but we're paranoid. if(end >= input.length) return __nullString; return new String(input, end, __inputEndOffset - end); } else if(__originalInput instanceof String) { String input; input = (String)__originalInput; // Just in case we make sure begin offset is in bounds. It should // be but we're paranoid. if(end >= input.length()) return __nullString; return input.substring(end, __inputEndOffset); } return __nullString; } /** * Returns the part of the input preceding the last match found as a * char array. This method eliminates the extra * buffer copying caused by preMatch().toCharArray(). * <p> * @return The part of the input preceding the last match found as a char[]. * If the result is of zero length, returns null instead of a zero * length array. */ public synchronized char[] preMatchCharArray() { int begin; char[] result = null; if(__originalInput == null) return null; begin = __lastMatch.beginOffset(0); if(begin <= 0) return null; if(__originalInput instanceof char[]) { char[] input; input = (char[])__originalInput; // Just in case we make sure begin offset is in bounds. It should // be but we're paranoid. if(begin >= input.length) begin = input.length; result = new char[begin - __inputBeginOffset]; System.arraycopy(input, __inputBeginOffset, result, 0, result.length); } else if(__originalInput instanceof String) { String input; input = (String)__originalInput; // Just in case we make sure begin offset is in bounds. It should // be but we're paranoid. if(begin >= input.length()) begin = input.length(); result = new char[begin - __inputBeginOffset]; input.getChars(__inputBeginOffset, begin, result, 0); } return result; } /** * Returns the part of the input following the last match found as a char * array. This method eliminates the extra buffer copying caused by * preMatch().toCharArray(). * <p> * @return The part of the input following the last match found as a char[]. * If the result is of zero length, returns null instead of a zero * length array. */ public synchronized char[] postMatchCharArray() { int end; char[] result = null; if(__originalInput == null) return null; end = __lastMatch.endOffset(0); if(end < 0) return null; if(__originalInput instanceof char[]) { int length; char[] input; input = (char[])__originalInput; // Just in case we make sure begin offset is in bounds. It should // be but we're paranoid. if(end >= input.length) return null; length = __inputEndOffset - end; result = new char[length]; System.arraycopy(input, end, result, 0, length); } else if(__originalInput instanceof String) { String input; input = (String)__originalInput; // Just in case we make sure begin offset is in bounds. It should // be but we're paranoid. if(end >= __inputEndOffset) return null; result = new char[__inputEndOffset - end]; input.getChars(end, __inputEndOffset, result, 0); } return result; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -