Package java.util.regex

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


        do { //use do while, due to the find() invocation above
          // test if it is all upper, and replace with all upper (if we have this set up in the regex itself - in config file)
          if (rp.getSameOutputCase() && allUpper && m.group().toUpperCase().equals(m.group())) {
            m.appendReplacement(sb, rp.executeString(env).toUpperCase());
          } else {
            m.appendReplacement(sb, rp.executeString(env));
          }
        } while (m.find());
        m.appendTail(sb);

        if (!preparedEffects.contains(rp)) {
View Full Code Here


        }
        final StringBuffer b = new StringBuffer();
        final Matcher m = varPattern.matcher(line);
        while(m.find()) {
            if (m.start() > 0 && line.charAt(m.start() - 1) != ESCAPE) {
                m.appendReplacement(b, Matcher.quoteReplacement(getValue(m.group(1))));
            } else {
                m.appendReplacement(b, m.group().substring(1));
            }
        }
        m.appendTail(b);
View Full Code Here

        final Matcher m = varPattern.matcher(line);
        while(m.find()) {
            if (m.start() > 0 && line.charAt(m.start() - 1) != ESCAPE) {
                m.appendReplacement(b, Matcher.quoteReplacement(getValue(m.group(1))));
            } else {
                m.appendReplacement(b, m.group().substring(1));
            }
        }
        m.appendTail(b);
        return b.toString();
    }
View Full Code Here

        Assert.hasLength(contentType, "'contentType' must not be empty");
        if (StringUtils.hasText(action)) {
            Matcher matcher = ACTION_PATTERN.matcher(contentType);
            if (matcher.find() && matcher.groupCount() == 1) {
                StringBuffer buffer = new StringBuffer();
                matcher.appendReplacement(buffer, "action=" + action);
                matcher.appendTail(buffer);
                return buffer.toString();
            }
            else {
                return contentType + "; action=" + action;
View Full Code Here

      // note: order matters
      replacement = replacement.replaceAll("\\\\", "\\\\\\\\");
      replacement = replacement.replaceAll("\\$", "\\\\\\$");

      matcher.appendReplacement(sb, replacement);
    }
    matcher.appendTail(sb);
    return sb.toString();
  }
View Full Code Here

        if(attr_name.contains("_")) {
            // Pattern p=Pattern.compile("_.");
            Matcher m=ATTR_NAME_TO_METHOD_NAME_PATTERN.matcher(attr_name);
            StringBuffer sb=new StringBuffer();
            while(m.find()) {
                m.appendReplacement(sb, attr_name.substring(m.end() - 1, m.end()).toUpperCase());
            }
            m.appendTail(sb);
            char first=sb.charAt(0);
            if(Character.isLowerCase(first)) {
                sb.setCharAt(0, Character.toUpperCase(first));
View Full Code Here

            if (asHtml) {
                insidePre = startPre(content, insidePre);
            }
            if (substText != null) {
                final StringBuffer substBuf = new StringBuffer();
                matcher.appendReplacement(substBuf, substText);
                // Remove prepended text between matches
                final String segment = substBuf.substring(matcher.start() - lastMatchEnd);
                appendMatchedSegment(content, segment, escapeHtml, matchedSegmentHtmlStyle);
            } else {
                appendMatchedSegment(content, matcher.group(), escapeHtml, matchedSegmentHtmlStyle);
View Full Code Here

            final StringBuffer sb = new StringBuffer();
            boolean matched = false;
            while (matcher.find()) {
                matched = true;
                if (substText != null) {
                    matcher.appendReplacement(sb, substText);
                } else {
                    break;
                }
            }
            if (matched) {
View Full Code Here

   */
  public static String toIRI(String uri) {
    StringBuffer decoded = new StringBuffer();
    Matcher matcher = percentEncoding.matcher(uri);
    while (matcher.find()) {
      matcher.appendReplacement(decoded, decode(matcher.group()));
    }
    matcher.appendTail(decoded);
    return decoded.toString();
  }
  private static final Pattern percentEncoding = Pattern.compile("(%[0-9a-fA-F][0-9a-fA-F])+");
View Full Code Here

        }
        // markdown link
        String name =  "\u261E " + m.group(1) ;
        String url = m.group(2);
        linkTargets.add(url);
        m.appendReplacement(sb, escapeReplacement(name));
        linkOffsets.add((sb.length() - name.length()) + 1);
        linkLengths.add(name.length());
      }
      else {
        // source location
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.