-
Enhancement
-
Resolution: Unresolved
-
P3
-
None
-
None
In Matcher, there are a couple of models for how to do find/replace sequences, but neither expose the ability to directly access the expanded replacement string, as evaluated internally by `Matcher.appendExpandedReplacement`.
Providing direct access to the expanded replacement would allow a user to support additional find/replace models, especially when matching against a CharSequence derived from an alternate representation for the string being matched.
The new method could be as simple as:
public String getExpandedReplacement(String replacement) {
return appendExpandedReplacement(replacement, new StringBuilder()).toString();
}
In other words, it can be a simple wrapper around existing functionality.
Currently, the only way to indirectly access the value is to use `Matcher.appendReplacement` and discard the first part of the value added in to the `StringBuilder`, which is pretty ugly.
Providing direct access to the expanded replacement would allow a user to support additional find/replace models, especially when matching against a CharSequence derived from an alternate representation for the string being matched.
The new method could be as simple as:
public String getExpandedReplacement(String replacement) {
return appendExpandedReplacement(replacement, new StringBuilder()).toString();
}
In other words, it can be a simple wrapper around existing functionality.
Currently, the only way to indirectly access the value is to use `Matcher.appendReplacement` and discard the first part of the value added in to the `StringBuilder`, which is pretty ugly.