Related Projects

Demonstration Applet

This demonstration requires the Java Plugin.

<hr /> If you can't see the demo applet, please try enabling Java in your browser or downloading the <a href="http://java.sun.com/products/plugin/index.html"> Java Plugin</a>. <hr />

Jakarta ORO's text processing classes support a wide range of features which are not demonstrated in this applet. Here we allow you to test for yourself the Perl5, AWK, and glob regular expression support from the org.apache.oro.text.regex, org.apache.oro.text.awk, and org.apache.oro.text packages. The Perl5 syntax demonstrated is Perl 5.003 compatible as of version 2.0.2. Remember, Perl5 compatibility means that zero-width lookahead assertions, greed control, backreferences, and other features are supported. This applet only demonstrates the basic functionality of the packages. The split and substitute methods of the Util class and other features are not demonstrated here. To get a better idea of what else you can do with Jakarta ORO, you should look through the API documentation.


Select a regular expression syntax in the topmost choice menu. Type a regular expression in the first text field. Then in the Search Input text area, enter text that you want to search. Click the Search button to search the input text. The results will appear in the Search Results text area. The Reset button will clear the regular expression, input, and result text.

There are two choice menus that affect the regular expression search. The contains() item causes the contains() method of the PatternMatcher interface to be used to perform the search. This search is done in a while loop, finding all pattern matches occuring within the input. The matches() item causes the matches() method of the PatternMatcher interface to be used to perform the search. The matches() method only tests if all the input EXACTLY matches the regular expression. It does not check to see if there is a match somewhere inside the input. That is what the contains() method is for. This is sometimes a point of confusion for users who have tried other packages. In Jakarta ORO, matches() is used to find exact matches, and contains is used to find a match contained in the input.

The Case Sensitive and Case Insensitive choice items are self-explanatory. Case Sensitive causes the regular expression to be compiled with case sensitivity enabled. Case Insensitive causes the regular expression to treat upper and lower case characters the same.

The Search Results text area will display all the matches found in the input when the contains() choice item is selected. It will also display what the parenthesized subgroups of a regular expression matched. When the matches() choice item is selected, only whether or not the input exactly matched the pattern is indicated.

Please note that if you don't enter anything for a regular expression, it will be compiled as an expression matching a zero-length string (the null string), which will match before and after every character in the input.

Copyright © 1999-2004, The Apache Software Foundation