Regular Expressions added to J2SE 1.4


News: Regular Expressions added to J2SE 1.4

  1. Regular Expressions added to J2SE 1.4 (12 messages)

    One item that always bugged me about Java was that regular expressions wasn't built into the language. Sure enough, 3rd party packages came about (ORO's work,, etc), but come on... put it in the core! The J2SE 1.4 Beta, contains a new package called java.util.regex, enabling the use of regular expressions.

    Read about this new package at
    Regular Expressions and the JavaTM Programming Language.

    Do you think it is as good as the apache (from ORO) package?

    Threaded Messages (12)

  2.     The danger of standardizing on packages like regular expresssions and logging is that it restricts innovation. Once the packages are established, whats the point of initiatives like Apache innovating to come with something better?

        The JDK is a great programming library, but is it possilble it is being over extended?

  3. I guess extending it is a double-edged sword. There are pro's and con's... In some ways I like the fact that I can be lazy and assume: "Oh there is a regex module in the JDK... it must be pretty good, so I may as well use it", instead of trying to hunt down the best third party one that exists.

    I really like the CPAN that Perl has. There is a central place to go to for modules, you get to learn about the authors and kinda work out "Oh I trust this module as Graham Barr is something to do with it".

    All of the great modules are not necessarily in the perl distribution, but they are easy to find
  4. What are you suggesting Floyd, that we go back to jdk 1.0? Of course it should be extended.
  5. <quote>
        The danger of standardizing on packages like regular expresssions and logging is that it restricts innovation. Once the packages are established, whats the point of initiatives like Apache innovating to come with something better?

    Nothing will stop a hacker from rewriting something from scratch just for the fun of it. Just because it's shipped in standard is certainly no deterrent.

    On the contrary, I believe it has a lot of benefits, such as:

    - Supply a yardstick against which you can measure your own work ("I can generate anchors for regexp faster than the version that Sun ships")

    - Offer a standard API that everybody can get familiar with before the implementation improves

    I don't really care about distribution size, I much prefer downloading something big that works right away rather than having the choice of fine-tuning and spending an extra two days doing so.

    Case in point, I just went through this hell twice this past week:

    - trying to install an RPM software that depended of half a dozen of other RPM's (rmpfind is of little help)

    - trying to install the latest jde and finding myself sifting throug sunsite first and then the entire world looking for .el that were not included

    Give me code bloat any day, hard disk space is much cheaper than my free time.

  6. Over-extending J2SE[ Go to top ]

    Much as I believe that j2se is being over extended, I have to admit that regexps were a missing package and it is good that 1.4 has included them. One would have expected them to be added in as far back as 1.0 or at least 1.1. I've always had to run to perl for text processing.

    We certainly need a CPAN equivalent for java instead of beefing up the core java. Certain libs in the new 1.4 should be just that. XML for instance needs not be in the core, maybe in the enterprise edition. A superpacked java wont affect innovation. It will make more like Microsoft Offce programs like MS Word which at this point is so packed with features that its almost incorrect to call it a Word Processor. A core should provide basic functionality rquired for useful small app. You want ftp, get a lib. Thats my take on this!
  7. So where is the &#8220;thin red line&#8221; Floyd. If in your opinion adding some of the new APIs regarding regular expression is restricting innovation, can&#8217;t it go against all the extended API (specially J2EE). At least it perfectly makes sense in case of regular expressions for the sake of core language completeness, because regular expressions are core of many interpreted scripting languages.
    Since the &#8220;new world order&#8221; ( software companies won&#8217;t compete on standards but implementation) there isn&#8217;t any chance for innovation any way. IMHO it is very hard for small companies to survive in that kind of environment.


  8. Why is it called "Regular Expressions"? The Sun site explains that these classes will be used for "Pattern Matching". Why don't we use the term "pattern matching" instead? I think "Regular Expressions" is about as vague as one can get. Can anyone tell me where this originated and why?

    Maybe "regular expressions" extends "pattern matching".

  9. Jeff:

    "Regular expression" is the name of a certain type of language defined in mathematical terms. You can then use expressions that are "regular" for things like pattern matching.
  10. Regular Expressions added to J2SE 1.4[ Go to top ]

    What are irregular expressions then?
  11. Regular Expressions added to J2SE 1.4[ Go to top ]

    As as was a Perl programmer before I was a Java programmer I have known the power and elegance of regular expressions for a long time. The first thing I did was when I learned java was then to look for a decent regex package (I was never so stupid as to use the abomination called StringTokenizer). I found that in the ORO package (now part of Apache). I have used it for a while and I will keep on using it as i think it's much better than the one that comes with JDK1.4. The one from JDK1.4 suffers from the same drawback as many other standard Java packages: It's very verbose. Thereby I mean that just to do a simple thing (like a match) you have to write a lot of lines of code where you could do with much less lines. In JDK1.4 regex package you will need to write something like 5 lines of code just for a simple match, creating a lot of objects in the process. In ORO (or perl for that matter) you can do all that in one line with one object. I't a pitty that sun thinks that the more objects you create to do something the more OO it is and hence better.

    Nevertheles since the average Java programmer never before has used regular expressions before, I am sure that the JDK1.4 regex package will be used a lot and become the standard (anybody remember JGL versus the JDK collections framework?) and hence when I will work on a project for some company I will be forced to use it anyway by some stupid project manager/java architect who just discovered the package and thinks he has found the holy grail for text processing.

    I totally agree with the opinion that it would be better to create something like the CPAN for Java instead of letting sun dictate the rest of the world how every possible API in Java should be and hence how we should program!

    Just my 5 cents

    Steven Sagaert
  12. Regular Expressions added to J2SE 1.4[ Go to top ]

        "As as was a Perl programmer before I was a Java
        programmer I have known the power and elegance of
        regular expressions for a long time."

    Elegance? I thouth you said you where a PERL programmer?
  13. Regular Expressions added to J2SE 1.4[ Go to top ]

    I agree that for many applications the API is too verbose. For optimization, though, it makes sense. Perl has an advantage that Regular Expressions are syntax of the language so the compiler can do special optimization. What I would like to see is a set of methods on the String object that implement match and split. These methods might not be as efficient as explicitly creating Pattern and Matcher objects. If you found you needed the extra efficiency then you could use them.