Regular Expressions in Java

Now they're faster!

I have written a package named "pat" to do regular expressions in java. It supports most of the perl5 syntax, and is documented in pages generated by javadoc. It works by treating each pattern element as a class which knows how to match itself and ask the next element to match itself. Because of this, you can extend class regex to match new syntax and pattern types.

Example of use

import pat.Regex;

public class tstRegex {
	public static void main(String[] notused) {
		Regex r = new Regex("[a-c]+([x-z]+)");
		r.search("abcxyz");
		System.out.println("match => "+r.substring());
		System.out.println("backrefernce 0 => "+r.substring(0));
	}
}
Which produces the output:
match => abcxyz
backreference 0 => xyz
You can get a good idea of how to use this package by seeing my quick start guide.

To install this software simply download this file pat10.zip.


Documetation can be found in the directory pat/doc if you install, or it may be read online. The best place to start is pat.Regex.html. It has everything you need to get started.

Some source files for examples can be found in:

If you wish to track new developments with this software, or if you would like to give me a suggestion, please send me email. I am interested in hearing about whatever would make you more likely to use this package, and am interested in hearing about whether you currently use it.

But, if you don't want to go to the trouble of downloading it, if you would rather just type in perverse patterns to try and break my library, then you can just do that below. Simply type a pattern in, then some text, then hit the return key to see the results of the match.

Or you could if you had a browser that supported java.

Or, if you are a really perverse individual, you could play my new regular expression game.


Differences from beta version

This is now release 1.0.

Differences from the alpha version

The new version differs in the following ways: