The list of methods to do Regex String Replace are organized into topic(s).
String
replace$(String text, Map vars) Replaces the variables present in the text and returns the result.
Each key will be added to the $ prefix.
return replace(text, vars, "$");
String
replace(Matcher m, String rv, Object value) replace
while (m.find()) {
if (m.group(2) != null) {
rv = rv.replace(m.group(0), String.format(m.group(2), value));
} else {
rv = rv.replace(m.group(0), String.valueOf(value));
return rv;
...
String
replace(Pattern pattern, String src, Function handler) Replace string with pattern obtaining replacement values through handler function.
StringBuilder sb = null;
Matcher matcher = pattern.matcher(src);
int pos = 0;
while (matcher.find()) {
if (sb == null) {
sb = new StringBuilder();
String expr = matcher.group();
...
String
replace(String content, String name, String value) replace
Pattern pattern = Pattern.compile("[{]" + name + "[}]");
Matcher matcher = pattern.matcher(content);
StringBuffer buf = new StringBuffer();
int curpos = 0;
while (matcher.find()) {
buf.append(content.substring(curpos, matcher.start()));
curpos = matcher.end();
buf.append(value);
...
String
replace(String input, Pattern regex, Function converter) Finds and replaces matches from the input string using the regex regular expression and the converter replacement function.
Matcher matcher = regex.matcher(input);
StringBuilder sb = new StringBuilder();
int lastPosition = 0;
while (matcher.find()) {
sb.append(input.substring(lastPosition, matcher.start()));
sb.append(converter.apply(matcher.group()));
lastPosition = matcher.end();
sb.append(input.substring(lastPosition));
return sb.toString();