Package java.util.regex

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


  @Override
  public Event intercept(Event event) {
    String origBody = new String(event.getBody(), charset);
    Matcher matcher = searchPattern.matcher(origBody);
    String newBody = matcher.replaceAll(replaceString);
    event.setBody(newBody.getBytes(charset));
    return event;
  }

  @Override
View Full Code Here


        Pattern pattern = Pattern.compile("([0-9]+) x ([0-9]+)");
        Matcher matcher = pattern.matcher(s);
        if (! matcher.matches()) {
            return null;
        }
        String numText = matcher.replaceAll("$1");
        String denText = matcher.replaceAll("$2");
        int num = Integer.parseInt(numText);
        int den = Integer.parseInt(denText);

        return new AspectConstraint(num, den);
View Full Code Here

        Matcher matcher = pattern.matcher(s);
        if (! matcher.matches()) {
            return null;
        }
        String numText = matcher.replaceAll("$1");
        String denText = matcher.replaceAll("$2");
        int num = Integer.parseInt(numText);
        int den = Integer.parseInt(denText);

        return new AspectConstraint(num, den);
    }
View Full Code Here

    TemplateKey(File file) {
        this.file = file;
        String fileName = file.getName();
        String baseName = FileUtil.trimExtensionOf(fileName);
        Matcher matcher = NamePattern.matcher(baseName);
        String encodedNamespace = matcher.replaceAll("$1");
        String encodedName = matcher.replaceAll("$2");
        namespace = FileUtil.decodeFilename(encodedNamespace);
        name = FileUtil.decodeFilename(encodedName);
    }
View Full Code Here

        this.file = file;
        String fileName = file.getName();
        String baseName = FileUtil.trimExtensionOf(fileName);
        Matcher matcher = NamePattern.matcher(baseName);
        String encodedNamespace = matcher.replaceAll("$1");
        String encodedName = matcher.replaceAll("$2");
        namespace = FileUtil.decodeFilename(encodedNamespace);
        name = FileUtil.decodeFilename(encodedName);
    }

    public String getName() {
View Full Code Here

            BufferedReader buffer = new BufferedReader(reader);
            String line = buffer.readLine();
            while (line != null) {
                Matcher matcher = pattern.matcher(line);
                if (matcher.matches()) {
                    String text = matcher.replaceAll("$1");
                    int i = Integer.parseInt(text);
                    return i / 1024;
                }
                line = buffer.readLine();
            }
View Full Code Here

            prefix = this.rm_.reverse(prefix);
        }

        try {
            Matcher m = P_URL.matcher(s);
            s = m.replaceAll("url(" + prefix + "$1)");
            return s;
        } catch (Throwable e) {
            System.err.println("Error process relative URL: " + fn);
            e.printStackTrace(System.err);
            return s;
View Full Code Here

    protected String regexReplace(String regex_pattern,
            String replacement, String s) {
        Pattern p = Pattern.compile(regex_pattern);
        Matcher m = p.matcher(s);
        return m.replaceAll(replacement);
    }

    protected String processTag(String s) {
        // ending tags
        Pattern p = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI);
View Full Code Here

        if(next == null) {
          matcher = patternReplacement.getKey().matcher(line);
        } else {
          matcher = patternReplacement.getKey().matcher(next);
        }
        next = matcher.replaceAll(patternReplacement.getValue());
      }
      if(next == null) {
        throw new RuntimeException("Woh nelly! This is bad. There is no reason this should ever happen!");
      }
      next += "\n";
View Full Code Here

            if (matcher.matches()) {
                ln = matcher.group(2);
                query = matcher.replaceFirst("$1$3");
                matcher = AMP_CLEANUP_PATTERN.matcher(query);
                if (matcher.matches()) {
                    query = matcher.replaceAll("$1$2$3");
                }
            }
            if (!query.isEmpty()) {
                buffer.append("?").append(query);
            }
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.