void append(MatchResult match, TextBuffer dest) { if (prefix != null) dest.append(prefix); if (index == null) return; int i = index; if (i >= match.pattern().groupCount()) return; if (match.isCaptured(i)) match.getGroup(i, dest, modes); }
public Matcher appendReplacement(StringBuffer sb, String replacement) { Replacer rep = internalPattern.replacer(replacement); Replacer.replaceStep(matcher, new PerlSubstitution(replacement), Replacer.wrap(sb)); return this; }
void append(MatchResult match, TextBuffer dest, boolean pass) { if (!pass) { if (prefix != null) dest.append(prefix); if (index == null) return; int i = match.pattern().groupId(index); if (match.isCaptured(i)) match.getGroup(i, dest, modes); } }
public static int indexOf(CharSequence text, String regex, int beginIndex) { matcher.setPattern(Pattern.compile(regex)); matcher.setTarget(text); matcher.setPosition(beginIndex); if(!matcher.find()) return -1; return matcher.start(); } public static int indexOf(CharSequence text, Pattern regex)
/** * Takes all occurrences of the pattern this was constructed with in text and replaces them with the substitution. * Appends the replaced text into sb. * @param text a String, StringBuilder, or other CharSequence that may contain the text to replace * @param sb the StringBuilder to append the result into * @return the number of individual replacements performed; the results are applied to sb */ public int replace(CharSequence text, StringBuilder sb) { return replace(pattern.matcher(text), substitution, wrap(sb)); }
@GwtIncompatible private int replace(Reader text, int length, TextBuffer dest) throws IOException { return replace(pattern.matcher(text, length), substitution, dest); }
@GwtIncompatible private static int replace(Matcher m, Substitution substitution, Writer out) throws IOException { try { return replace(m, substitution, wrap(out)); } catch (WriteException e) { throw e.reason; } }
private static void initNamedCategory(String name) { BlockSet bs = new BlockSet(); bs.setCategory(name); registerClass(name, bs, unicodeCategories); }
static int parseClass(char[] data, int i, int out, Term term, boolean icase, boolean skipspaces, boolean unicode, boolean xml) throws PatternSyntaxException { BlockSet bs = new BlockSet(); i = parseClass(data, i, out, bs, icase, skipspaces, unicode, xml); BlockSet.unify(bs, term); return i; }
/** * A shorthand for Pattern.matcher(String).matchesPrefix().<br> * * @param s the target * @return true if the entire target matches the beginning of the pattern * @see Matcher#matchesPrefix() */ public boolean startsWith(String s) { return matcher(s).matchesPrefix(); }
/** * Tokenizes a specified region by an occurrences of the pattern. * Note that a series of adjacent matches are regarded as a single separator. * The same as new RETokenizer(Pattern,Reader,int); * * @see RETokenizer * @see RETokenizer#RETokenizer(regexodus.Pattern, java.io.Reader, int) */ @GwtIncompatible public RETokenizer tokenizer(Reader in, int length) throws IOException { return new RETokenizer(this, in, length); }
void append(MatchResult match, TextBuffer dest) { if (prefix != null) dest.append(prefix); if (index == null) return; //if(id==null) return; //??? int i = match.pattern().groupId(index); if (match.isCaptured(i)) match.getGroup(i, dest, modes); }
@GwtIncompatible public void replace(MatchResult res, int group, Writer out) throws IOException { replace(pattern.matcher(res, group), substitution, out); }
/** * Tokenizes a specified region by an occurrences of the pattern. * Note that a series of adjacent matches are regarded as a single separator. * The same as new RETokenizer(Pattern,Reader,int); * * @see RETokenizer * @see RETokenizer#RETokenizer(regexodus.Pattern, java.io.Reader, int) */ @GwtIncompatible public RETokenizer tokenizer(Reader in, int length) throws IOException { return new RETokenizer(this, in, length); }
void append(MatchResult match, TextBuffer dest) { if (prefix != null) dest.append(prefix); if (index == null) return; //if(id==null) return; //??? int i = match.pattern().groupId(index); if (match.isCaptured(i)) match.getGroup(i, dest, modes); }