regular expressions in java

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 an 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
To install this software you can either use the standard pat.tar.gz or do the following:
  1. Download suitcase.class.
  2. Execute the command:
    java suitcase
    This will create a directory named "pat" in the current directory and install all needed files there.
  3. Set CLASSPATH appropriately.

You can also download a few test files if you like:
deriv.java This file demonstrates how you can extend class regex to compile new patterns. tokenTest.java an example of what the regexTokenizer does.

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.

If you wish to track new developments with this software, please send me email.

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 the alpha version

This is now the beta version, although I still make the alpha accessible. The new version differs in the following ways:

Release 1.0

This will focus on making the package faster. I am also considering including a few more new pattern types (always beginning with a "(?"). I am considering, for example, making a type of backreference with a variable name "(?'a'" would store the backreference in a variable named "a", rather than in "0", "1", "2", etc.