-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strings.replaceAll(target, regex, fn(MatchResult, String)) #651
Comments
Original comment posted by [email protected] on 2011-07-13 at 06:32 PM Something almost exactly like this exists in the internal Google codebase; it was one of the first libraries I contributed ~5 years ago and almost no one has ever used it. :) Status: |
Original comment posted by [email protected] on 2011-07-13 at 07:00 PM (No comment entered for this change.) Labels: |
Original comment posted by [email protected] on 2011-07-13 at 07:42 PM (No comment entered for this change.) |
Original comment posted by [email protected] on 2011-12-10 at 04:12 PM (No comment entered for this change.) Labels: |
Original comment posted by [email protected] on 2012-02-16 at 07:17 PM Possibly related: bug 383 |
Original comment posted by [email protected] on 2012-02-16 at 07:17 PM (No comment entered for this change.) Status: |
Original comment posted by wasserman.louis on 2012-02-16 at 07:19 PM Issue #383 has been merged into this issue. |
Original comment posted by [email protected] on 2012-02-16 at 07:20 PM I think something might need to be done in this area but we need to mount a small research project to understand exactly what, and that is probably not high-priority at the moment. |
Original comment posted by [email protected] on 2012-05-30 at 07:43 PM (No comment entered for this change.) Labels: - |
Original comment posted by [email protected] on 2012-06-22 at 06:16 PM (No comment entered for this change.) Status: |
I've started an implementation that matches exactly, not based on regex, but I guess it can easily be improved. It can be seen here: https://gist.github.com/ogregoire/8c95bd3ab7c7e670a5012caad47125e3 If I'm not lost in other considerations, I'll try to make this into a guava-like class and create a PR. Any remarks, comments is welcome. |
Original issue created by pholser on 2011-07-07 at 01:52 AM
A possible implementation:
public class Strings {
private Strings() {
throw new UnsupportedOperationException();
}
}
I'm ambivalent about whether to make the type of 'regex' a Pattern or leave it as a String for the method to compile().
Motivation: To allow global replacement of matches with the result of a function of the match result, a la C#'s Regex.Replace(string, MatchEvaluator). PITA to roll the appendReplacement/appendTail bit by hand.
The text was updated successfully, but these errors were encountered: