XML technologies / Regular expressions / Java / Differences between versions of Java.
(Excerpt from "Regular expressions" by Jeffrey E. F. Friedl)
As mentioned at the beginning of this chapter, this book mainly describes Java 1.5.0. However, Java 1.4.2 is still widely used, while Java 1.6 is becoming increasingly common. I therefore summarize the differences between versions 1.4.2, 1.5.0 (Update 11), and Java 1.6 (Update 1).
Differences between Java 1.4.2 and 1.5.0
In Java 1.5.0, java.util.regex has changed little compared with 1.4.2, but several methods have been added. These mainly concern the matcher’s region. Support for Unicode has been improved and slightly changed. All changes are listed below. (Note: Java 1.4.2 had the undocumented construct ˹(?1)˼, which is absent in Java 1.5. It behaves just like the corresponding PCRE construct (see Recursive regular expressions), but since it was never documented, it is relegated here to a footnote.)
New methods in Java 1.5.0
Everything involving the matcher’s region was absent in Java 1.4.2:
regionregionStartregionEnduseAnchoringBoundshasAnchoringBoundsuseTransparentBoundshasTransparentBounds
The following methods are also new in Java 1.5:
toMatchResulthitEndrequireEndusePatterntoString
The following static method was absent in Java 1.4.2:
Pattern.quote
Unicode differences between Java 1.4.2 and 1.5.0
The following changes were made between versions 1.4.2 and 1.5.0:
Java 1.5 supports Unicode 4.0.0, whereas Java 1.4.2 supported Unicode 3.0.0. This affects character definitions (Unicode 3.0.0 had no code points above
\uFFFF), their properties, and Unicode block definitions.The syntax for Unicode block names using
˹\p{...}˼and˹\P{...}˼has been improved. (The supported blocks and their names are listed in the Java documentation forCharacter.UnicodeBlock).Java 1.4.2 used the rule “official Unicode block name without spaces, prefixed by ›
In‹”. This produced names such as\p{InHangulJamo}or\p{InArabicPresentationForms-A}.Java 1.5 added two new forms of Unicode block names. One simply prefixes the official block name with ›
In‹, giving\p{InHangul●Jamo}and\p{InArabic●Presentation●Forms-A}. The other prefixes ›In‹ to the Java block name, obtained by replacing spaces and hyphens in the official name with underscores. Thus one may also write:\p{InHangul_Jamo}and\p{InArabic_Presentation_Forms_A}.Java 1.4.2 had a bizarre bug: for the block names Arabic Presentation Forms-B and Latin Extended-B, the final “B” had to be written “Bound”, giving
\p{InArabicPresentationForms-Bound}and\p{InLatinExtended-Bound}.In Java 1.5.0, regular expressions support the methods
isIrgendwasof theCharacterclass (see Special Java properties).
Differences between Java 1.5.0 and 1.6
By the second Java 1.6 beta, only two small regex-related changes had been added:
The Unicode categories Pi and Pf are now supported.
The construct
˹\Q...\E˼also works inside character classes in Java 1.6.
German edition copyright © 2008 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for private use.
Otherwise, this chapter from "Reguläre Ausdrücke" is subject to the same terms as the bound edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln