package gnu.regexp - Regular Expressions for Java

`package gnu.regexp;`

Change History
This page was last updated on 21 October 2001

1.1.4 (21 October 2001)
Patch to Makefile to include language resource files in the applet JAR. (Andrew G. Hammond)
Updates to gnu.regexp.util.Grep to add "-z" option, expand ZIP files. (Ulf Dittmer)
Some updates and clarifications to Javadoc, especially for substitute() methods. (Wes Biggs)
Fix to RE constructor for some uses of alternation operator failing due to minimumLength being set incorrectly. (Marcus Abels)
Added UncheckedRE subclass to provide constructors that are declared without exceptions (useful for static initializers). (Wes Biggs)
The getMatchEnumeration() methods that took an integer index offset resulted in REMatch objects with incorrect values for their start and end indices (the correct text was matched, but the values from getStartIndex() and getEndIndex() methods were incorrect). This has been fixed. (Wes Biggs)

1.1.3a (18 June 2001)
No code changes; distribution was missing a file.

1.1.3 (18 June 2001)
Change method signatures in REFilterReader to correctly override the Reader interface. Patch from Doug Seifert.
Fixed a bug in getMinimumLength() for expressions using alternation; because of this and the optimization introduced in 1.1.2, some matches were failing. (Wes Biggs)
Il8n support: all error messages are now stored in MessagesBundle.properties (Alan Moore)
Lookaheads, both positive and negative, are now supported, thanks to a patch from Shashank Bapat.
Parse intervals more in accordance with POSIX, i.e., if they don't exactly match one of {n}, {n,}, or {n,m}, the characters are matched literally. (Alan Moore)
Throw more exceptions when quantifiers (?, *, +, {}) appear in places where they are invalid, e.g., after a zero-width assertion (word boundary, lookahead), or after another quantifier. (Alan Moore)
Fixed two instances where incomplete patterns would cause ArrayIndexOutOfBoundsExceptions instead of REExceptions. (Alan Moore)
ASCII escapes \n, \r, and \t in [] lists are now supported. (Alan Moore)

1.1.2 (11 April 2001)
Fix REMatchEnumeration handling zero-length matches.
Declare classes "final" as much as possible, for speed.
Optimize match loop by checking remaining buffer against minimum length.
Fix '\b' and '\<' support to work correctly if before any consuming operators in the RE. Thanks to Alan Moore for identifying the problem and a fix.
Correct support for '^' in multiline match mode when used with an InputStream or Reader. Thanks to James Flynn for his suggestions and contributions.
Code cleanup to get rid of some bizarre variable names and so forth.

1.1.1 (16 February 2001)
Better leftmost longest support (re-fixes alternation isMatch() issue).
Fix for over-consuming behavior of character class/alternation.
Fixed subexpression index reporting.
Support for '\b', '\B', '\<' and '\>'.

1.1.0 (6 February 2001)
Many internal changes should result in speed increases.
Fixed an issue where subexpression indices would not be correctly saved, causing StringIndexOutOfBoundsExceptions to be thrown from REMatch.
Fixed a bug where subexpressions would not be found when nested and combined with alternation. (For example, "((A)B|(C)D)" would match "AB", but would not report subexpression #2.)
Fixed a bug compiling expressions of the form "(())a".
Fixed a problem where using the empty string as replacement text within a REFilterInputStream would throw an exception.
Added a FAQ in the docs directory. Added known bugs to the TODO.
Added REG_NO_INTERPOLATE execution bit, which allows substitution text to include $1-$9 without being interpolated. Suggested by Daniel Lescohier.
Lee Sau Dan submitted support for using Readers, providing both CharIndexedReader and REFilterReader classes. As a consequence, this version is no longer compatible with JDK 1.0. However, Readers provide much better support for reading text in various encodings, and the use of InputStream to do the same has been deprecated.
Clarified (in the javadoc) the semantics of getAllMatches() and substituteAll() when combined with REs that may match the empty string.
RE constructors and match functions will convert any unrecognized Object input to a String using the class's toString() method, so it is no longer possible to get IllegalArgumentExceptions. Suggested by Nic Ferrier.
Regular expressions are now serializable. Of course, it may be nearly as efficient to send the pattern string and recompile the RE on the other side.
Incorporated a patch from Oleksandr Lytvyn to allow RE.isMatch() to return true if any alternation in the pattern allows the full input to be matched, not just the first alternation.
Altered the [:print:] character class to correctly match all printable characters and space, not just alphanumerics. Caught by Richard Trahan.
The alphanumeric match sequence (\w) now matches the underscore (_) character. Thanks to Aryaguna for pointing out the discrepancy.
The start (^) and end ($) tokens, when used in multiline mode, now recognize multi-character newline sequences. In related news, you can override the platform-dependent line separator string by calling the setLineSeparator() method on RESyntax. REApplet has been modified to use this approach.
Predefined RESyntax objects are now immutable, and attempts to modify them throw IllegalAccessErrors. User-defined syntaxes can also be made immutable by calling the makeFinal() method.
RESyntax.clear(int) has been introduced as a parallel to RESyntax.set(int).
CharIndexed is now a public interface, enabling developers to provide their own implementations that may be passed into getMatch(). Suggested by Ernie Rael.
Expressions ending with an open subexpression token ('(') now correctly throw compilation exceptions.
Noted in the documentation for REMatch.toString(int) that the index is one-based. Thanks to Daniel Rall for bringing it to attention.
Fixed documentation note error regarding REG_DOT_NEWLINE. Thanks to Christophe Vigny for pointing this out.
Deprecated getSub(Start|End)Index(int) in favor of the new get(Start|End)Index(int) overloading. Added a note in the JavaDoc that these are zero-based indices, per a suggestion by Chris Cobb.
Fixed a bug where the regular expression "^$" would not match an empty string (or empty line, in multiline mode). Many thanks to James Jensen.
Added better file condition error handling code to Grep utility, courtesy of Jon Schewe.
The license (COPYING.LIB) has been changed to the GNU Lesser General Public License (the successor of the Library GPL). The change is only in name.

1.0.8 (21 March 1999)
Fixed handling of POSIX character classes (not used in default syntax).
Added Tap, the evil water droplet, to the home page (thanks to Jim Blair, corvus@gnu.org).
Changed the demo applet to support selectable syntax.

1.0.7 (3 March 1999)
Fixed NullPointerException when compiling expressions starting with '+' or '*'.
Fixed reporting of subexpression start indices in certain cases.
Removed static initializer in REToken.java to aid in compiling on non-compliant platforms.
Fixed endless loop caused by array read in REFilterInputStream.
Fixed ArrayIndexOutOfBoundsExceptions that could be thrown from REMatch.toString(int).
Updated all doc comment versions to 1.0.7.
Added a few tests to the test cottage (it's not big enough to be a suite).

1.0.6 (18 November 1998)
Fixed bug in subexpression position reporting.
Fixed some bugs with zero-length regular expressions.
More documentation for gnu.regexp.util classes.
Makefile changes for Cygwin compatibility.
Added credits.html file.
Fixed paths to API docs in HTML.

1.0.5 (8 November 1998)
Added gnu.regexp.REFilterInputStream class.
New directory structure for distribution.
Added gnu.regexp.util.Tests class, a limited testsuite.
Fixed bug in backreferences (\1, \2...) introduced in 1.0.4.
Fixed bug in handling of literal '-' within bracketed lists.
Changes to Makefile to work with Cygnus/Win32 systems.
General enhancements to Makefile.
Added TODO and CONTENTS files to distribution.
Added support for Perl5 escapes (\w,\d,\s, etc.) within bracketed lists.
Added matching syntax bit, RE_CHAR_CLASS_ESC_IN_LISTS.

1.0.4 (8 October 1998)
Added getMinimumLength method.
Added Makefile to distribution.
Added HTML to distribution.
Added gnu/regexp/util/REApplet.java demo applet to distribution.
Added support for pure grouping (?:...) operator.
Added support for comment (?#...) operator.
Minor changes for compatibility with guavac compiler.
Fixed some quirks with including dashes in lists.
Fixed some documentation errors.
Fixed 1.0.3 bug in REMatch reporting skipped subexpressions.
Fixed some major problems with alternation nested in subexpressions.
Fixed some pathological cases that would cause infinite loops.

1.0.3 (19 August 1998)
Added REMatchEnumeration and getMatchEnumeration methods.
Added support for compiling patterns from StringBuffers.
Added support for matching, substituting, searching against StringBuffer, char[] and InputStream.
Added toString(int) to REMatch to get subexpression matches easily.
Added getMatch() with StringBuffer argument to save contents leading up to a match.
substitute() and substituteAll() can now take $0 - $9 metacharacters.
General optimizations.
Source code cleanup, toward GNU coding standards.
More and better javadoc documentation.
getAllMatches() now returns non-overlapping matches as it should.
All classes in 1.0.3 are JDK 1.0.2 compatible and should work in applets.
RETest is no longer in the JAR as it is not needed in an execution environment. Source code is provided in the gnu/regexp/util directory.
gnu/regexp/util also contains a pure-Java implementation of GNU grep and egrep, for your amusement and use on non-GNU operating systems which lack such rudimentary text processing facilities. Grep and Egrep require gnu.getopt to compile and run.
Note that due to certain API changes, you will need to recompile any source code that uses gnu.regexp against the 1.0.3 classes. No code changes are necessary.

1.02a (23 July 1998)
No code changes. Added README, changed LICENSE to LGPL and changed copyright messages on source files. JAR file compiled with -O flag.

1.02 (15 June 1998)
Support for nested subexpressions. More debugging support. Fixed bug when escaping braces with a backslash.

1.01 (1 June 1998)
Fixed bug in list operator ( [...] ) which was causing the RE compiler to interpret the closing ']' as a literal.

1.00 (22 May 1998)
New API using RESyntax. New framework for "multiline" and "single line" matching. Default support for most Perl 5 constructs, including the following operators: \A, \d, \D, \w, \W, \s, \S, \Z, stingy matching (*?, ??, +?). Some string optimizations should speed up most matches. REG_NEWLINE wasn't working correctly in 0.07, it's gone and replaced by REG_MULTILINE (semantics matching Perl's "/m" operator). Support for POSIX character classes such as [:alpha:] within lists. General code cleanup and added comments.

0.07 (10 April 1998)
Added more default-argument versions of methods; added REG_ANCHORINDEX flag for substring processing; fixed bug in isMatch() for expressions with top-level branches; fixed bug in getMatch() for zero-length input never matching.

0.06 (3 March 1998)
First general release.

[gnu.regexp] [syntax and usage] [api documentation] [test applet] [faq] [credits]