Name: bsC130419 Date: 06/04/2001
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
Since Perl-style regular expressions are finally making their way into the SDK,
and even into the String class with split (a function for which I'm very
grateful :-), it would be very helpful to overload the replace method in the
String class to use regular expressions as well. A proposed method signature:
public String replace(String regex,String newText)
The function would operate on a String and replace all matches of the given
regex with the new text. The net result would be a function that works similar
to Perl's substitute functions.
If you're going to have regex, you might as well have substitution. That's half
the usefulness of regular expressions. I'll code it, if you like.
Another alternative would be to call the new method "substitute", as in Perl.
I know the Matcher class has a replaceAll method, but it would be helpful to
have it directly in String.
(Review ID: 125778)
======================================================================
- duplicates
-
JDK-4072400 New I/O: Regular-expression API
-
- Resolved
-