XML technologies / Regular expressions / Java
(Excerpt from "Regular expressions" by Jeffrey E. F. Friedl)
Since version 1.4 in early 2002, Java has included a regex package. It is a comprehensive, innovative implementation with a clean, sometimes rather minimal API. Unicode is supported quite well, the documentation is clear, and performance is good. Applying regexes to CharSequence objects makes the package flexible to use.
The original version of java.util.regex was a milestone. From the outset, the package was rich, fast, and almost free of teething problems. The final 1.4 release was Java 1.4.2. At press time, Java 1.5.0 (also called Java 5.0) was current, while Java 1.6.0 (also Java 6.0, code name “Mustang”) was in beta testing. This book covers Java 1.5.0’s regex package, but also discusses important differences from 1.4 and 1.6, listed again at the end of the chapter (see Differences between Java versions). (Note: this book covers Java 1.5.0 Update 7. The initial 1.5 release had a serious case-insensitive matching bug, fixed in Update 2; avoid earlier updates.
At the time of the German translation, Java 1.5 Update 11 was already available and Java 6.0 Update 1 was current. All examples were tested with the newer versions. —German translator’s note.)
In this chapter
Before outlining the contents, I should mention what is not included here. First, this chapter does not repeat all the material from Introduction to regular expressions through The art of writing regular expressions. A Java programmer may understandably want to jump straight to this chapter, but would miss the foundations from the introduction and early chapters. Introduction to regular expressions through Features and dialects explain the basic regex concepts, features, and techniques; How regex engines work through The art of writing regular expressions teach key regex techniques directly applicable to java.util.regex. These foundations include how an NFA regex engine works, greedy regex behavior, Backtracking, and regex efficiency considerations.
Table: alphabetically sorted index of java.util.regex methods.
Methods from | ||
|---|---|---|
Reference tables such as Regex modes in java.util.regex or Constructs covered in this section and Basic Unicode subproperties are certainly helpful, but this book is not primarily a lookup manual. Its main aim is to explain in detail how regular expressions work.
Earlier chapters introduced examples using java.util.regex (see Doubled words in Java, Using regular expressions in Java, Search and replace in Java, Parsing CSV files with Java, Benchmarking with Java); further examples follow as we discuss classes and their use in this chapter.
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