I\'m trying to do something like this:
public String evaluateString(String s){
Pattern p = Pattern.compile(\"someregex\");
Matcher m = p.matcher(s);
It seems that you are looking for Matcher#appendReplacement and Matcher#appendTail.
appendReplacement
will do two things:
appendTail
will add to buffer text placed after current match.
Pattern p = Pattern.compile("someregex");
Matcher m = p.matcher(s);
StringBuffer sb = new StringBuffer();
while (m.find()) {
m.appendReplacement(sb, methodFoo(m.group()));
}
m.appendTail(sb);
String result = sb.toString();