jrexx - automaton based regluar expression API for Java

D O C U M E N T A T I O N


REQUIREMENTS

jrexx is implemented in 100% pure Java and requires the Java 2 Plattform Standard Edition (J2SE) version 1.3.x (or greater) on the target computer.

API DOCUMENTATION

For a complete API documentation please see the jrexx API documentation pages (JavaDoc).

REGULAR EXPRESSION SYNTAX

For the complete jrexx regular expressions syntax please see the jrexx syntax definition.

QUICKSTART

These lines provide a really quick quickstart of the jrexx library usage.

EXAMPLE PATTERNS

The following list contains some ready-to-use patterns for common tasks. All patterns are ready to be used inside java source code, especially the escape sequences for special characters (like "." or "\") are already applied.

HOW TO SERIALIZE AUTOMATONS

jrexx is able to save/serialize and load/deserialze automatons using the serializable FSAData class (a kind of value object), which might be "XML-able" in future. The FSAData class should be the fundament for the interchange of automatons between different apps/tools. For example, jrexx-Lab's 'load' and 'safe' functionality works with FSAData. So you can visualize and test automatons with jrexx-Lab, even if your automaton has not been built with the jrexx API.

There is more than one way to save/serialize an automaton

  1. Serializing using jrexx-Lab
    create your regular expression with jrexx Lab and save it to disk.
  2. Serializing using PAutomaton
    PatternPro pattern = new PatternPro("[0-9]+");
    
    FileOutputStream out = new FileOutputStream(filename);
    pattern.getAutomaton().toData(out);
    out.close();
    
  3. Serializing using ObjectOutputStream
       PatternPro pattern = new PatternPro("[0-9]+");
       FSAData data = pattern.getAutomaton().toData();
    
       FileOutputStream out = new FileOutputStream(filename);
       new ObjectOutputStream(out).write(data);
       out.close();
    

Loading/Deserializing an automaton

  1. Deserializing using jrexx-Lab
    load and serialized automaton with jrexx-Lab
  2. Deserializing using PAutomaton
       FileInputStream in = new FileInputStream(filename);
       PatternPro pattern = new PatternPro(new PAutomaton(in));
       in.close();
    
  3. Deserializing using ObjectInputStream
       FileInputStream in = new FileInputStream(filename);
       FSAData data = (FSAData)ObjectInputStream(in).readObject();
       in.close();
       PatternPro pattern = new PatternPro(new PAutomaton(data));
    

All results of these examples for serialisation are compatibe to each other, but differ because of optional information.

Example c): Only FSAData is serialized.
Example b): PAutomaton serializes the FSAData and the regular expression string.
Example a): PAutomaton serializes the FSAData and the regular expression string. jrexx-Lab appends the graphical positions of the states to the stream.

Since the regular expression string and the positions are optional, you can serialize an automaton with jrexx-Lab and deserialize it using PAutomaton or ObjectInputStream.

USING JREXXLITE

jrexxLite is a subset of the jrexx API and a very small library (currently 23KB) for pattern matching. jrexxLite contains the DFASet class, that provides the same matching functionality as the Pattern class does. Both DFASet and Pattern use a deterministic finite state automaton (DFA), but Pattern creates a DFA from a given regular expression whereas DFASet needs an already created DFA in the form of FSAData (see new feature).