Which way is more efficient to replace characters/substring in a string. I have searched and i have found two ways :
output = output.replaceAll(REGEX, REPLACEMENT);
or
Pattern p = Pattern.compile(REGEX);
Matcher m = p.matcher(output);
output = m.replaceAll(REPLACEMENT);
I mean with efficiency : less time, loops and/or new variables.