Examples of appendReplacement()


Examples of java.util.regex.Matcher.appendReplacement()

    StringBuffer s = new StringBuffer();
    while (m.find()) {
      String replacement = getFieldAndFormat(m.group(), entry, database);
      if (replacement == null)
        replacement = "";
      m.appendReplacement(s, replacement);
    }
    m.appendTail(s);

    return s.toString();
  }
View Full Code Here

Examples of java.util.regex.Matcher.appendReplacement()

  public static String removeSingleBracesAroundCapitals(String s) {
    Matcher mcr = bracedTitleCapitalPattern.matcher(s);
    StringBuffer buf = new StringBuffer();
    while (mcr.find()) {
      String replaceStr = mcr.group();
      mcr.appendReplacement(buf, replaceStr.substring(1, replaceStr.length() - 1));
    }
    mcr.appendTail(buf);
    return buf.toString();
  }
View Full Code Here

Examples of java.util.regex.Matcher.appendReplacement()

  public void test_appendReplacement() {
    Pattern p = Pattern.compile("(\\d+)(\\w+)");
    Matcher m = p.matcher("jjj123www");
    m.find();
    StringBuffer sb = new StringBuffer();
    m.appendReplacement(sb, "|$2|");
    assertEquals("jjj|www|",sb.toString());
  }

  public void test_appendReplacement_with_escape_doler_char() {
    Pattern p = Pattern.compile("(\\d+)(\\w+)");
View Full Code Here

Examples of java.util.regex.Matcher.appendReplacement()

                if (!tagname.equals("interface")) {
                    String content = encodeSpecialSymbols(matcher.group(2));
                    if (tagname.equals("link")) {
                        content = getDocUrl(content);
                    }
                    matcher.appendReplacement(sb, s1 + content + s2);
                }
            }
            matcher.appendTail(sb);
            return sb.toString();
        } else {
View Full Code Here

Examples of java.util.regex.Matcher.appendReplacement()

                        if (contents == null) {
                            contents = new ArrayList<String>();
                            savedTags.put(text, contents);
                        }
                        contents.add(content);
                        matcher.appendReplacement(sb, "");
                    } else {
                        matcher.appendReplacement(sb, preKey + tagname + postKey + content + postValues);
                    }
                }
            }
View Full Code Here

Examples of java.util.regex.Matcher.appendReplacement()

                            savedTags.put(text, contents);
                        }
                        contents.add(content);
                        matcher.appendReplacement(sb, "");
                    } else {
                        matcher.appendReplacement(sb, preKey + tagname + postKey + content + postValues);
                    }
                }
            }
            matcher.appendTail(sb);
            // remove @endMarker
View Full Code Here

Examples of java.util.regex.Matcher.appendReplacement()

        final Matcher matcher = pattern.matcher(self);
        if (matcher.find()) {
            final StringBuffer sb = new StringBuffer(self.length() + 16);
            do {
                String replacement = getReplacement(matcher, closure);
                matcher.appendReplacement(sb, Matcher.quoteReplacement(replacement));
            } while (matcher.find());
            matcher.appendTail(sb);
            return sb.toString();
        } else {
            return self;
View Full Code Here

Examples of java.util.regex.Matcher.appendReplacement()

    public static String replaceFirst(final String self, final Pattern pattern, final Closure closure) {
        final Matcher matcher = pattern.matcher(self);
        if (matcher.find()) {
            final StringBuffer sb = new StringBuffer(self.length() + 16);
            String replacement = getReplacement(matcher, closure);
            matcher.appendReplacement(sb, Matcher.quoteReplacement(replacement));
            matcher.appendTail(sb);
            return sb.toString();
        } else {
            return self;
        }
View Full Code Here

Examples of java.util.regex.Matcher.appendReplacement()

    System.out.println(m.find());
    System.out.println(m.groupCount());
    System.out.println(Pattern.matches("<#(.*)/>", clause));
    System.out.println(m.group(1));
    StringBuffer sb = new StringBuffer();
    m.appendReplacement(sb, "[#$1/]");
    System.out.println(sb);

    System.out.println(Pattern.matches("template", clause));

    Pattern p = Pattern.compile("(cat)");
View Full Code Here

Examples of java.util.regex.Matcher.appendReplacement()

    Pattern p = Pattern.compile("(cat)");
    Matcher m1 = p.matcher("one cat two cats in the yard");
    StringBuffer sb1 = new StringBuffer();
    while (m.find()) {
      m1.appendReplacement(sb1, "dog");
    }
    m1.appendTail(sb1);
    System.out.println(sb1.toString());
    System.out.println("one cat two cats in the yard".replaceAll("cat", "dog"));
    System.out.println(clause.replaceAll("<#(.*)/>", "[#$1/]"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.