1 package com.aurea.maven.plugins.sonic.utils;
2
3 import java.util.regex.Matcher;
4 import java.util.regex.Pattern;
5
6 public class RegexUtil {
7
8
9
10
11
12
13
14
15
16 public static String applyReplaceFunction(String text, String str, String replacement) {
17
18 Pattern pattern = Pattern.compile("#\\{([^\\}]*)\\}");
19 Matcher matcher = pattern.matcher(text);
20
21 StringBuffer result = new StringBuffer();
22 while (matcher.find()) {
23 String argument = matcher.group(1);
24 matcher.appendReplacement(result, argument.replace(str, Matcher.quoteReplacement(replacement)));
25 }
26 matcher.appendTail(result);
27
28 return result.toString();
29 }
30
31 }