Class regexp.Regexp
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class regexp.Regexp

java.lang.Object
   |
   +----regexp.Regexp

public class Regexp
extends Object
A Regexp is a piece of a regular expression. The system is designed to be at once flexible and efficient. Therefore, very little allocation is done while matching a regexp. It's mostly all done during the compilation stage. Here's an example of how to use this class: import starwave.util.regexp.*; Regexp reg = Regexp.compile("^([a-z]*) ([0-9]*)"); String buffer = readFileIntoString("somefile.text"); Result result; int pos = 0; while ((result = reg.searchForward(buffer, pos)) != null) { System.out.println("Matched " + result.getMatch(1) + " and " + result.getMatch(2)); pos = result.matchEnd() + 1; }

Method Index

 o compile(String)
 o compile(String, boolean)
Return a compiled regular expression.
 o main(String[])
 o match(char[], int, int)
Returns true if the specified String is matched by this regular expression.
 o match(State)
Walks as far as it can down a regular expression, returning true if it made it all the way to the end, and false otherwise.
 o match(String, int)
Returns true if the specified String is matched by this regular expression.
 o searchBackward(char[], int, int)
Returns true if the specified char array is matched from the specified offset backward by this regular expression.
 o searchBackward(String, int)
Returns true if the specified String is matched from the specified offset backward by this regular expression.
 o searchForward(char[], int, int)
Returns true if the specified char array is matched anywhere by this regular expression.
 o searchForward(String, int)
Returns true if the specified String is matched anywhere by this regular expression.
 o toString()
 o toStringThis()

Methods

 o compile
  public static Regexp compile(String expr)
 o compile
  public static Regexp compile(String expr,
                               boolean mapCase)
Return a compiled regular expression. A compiled expression consists of a bunch of Regexp subclasses linked together in a double linked list. The only reason for prev pointers is to easily handled Multi processing, where you have to splice into the list sometimes.
 o match
  protected boolean match(State state)
Walks as far as it can down a regular expression, returning true if it made it all the way to the end, and false otherwise. When false, restores state to original state.
 o match
  public Result match(String data,
                      int offset)
Returns true if the specified String is matched by this regular expression. This is not to be confused with search, which looks all through the string for a match. This just looks to see if the beginning of the string matches.
Parameters:
data - string to match
Returns:
a regexp.Result on success, null on failure
See Also:
Result
 o match
  public Result match(char data[],
                      int offset,
                      int length)
Returns true if the specified String is matched by this regular expression. This is not to be confused with search, which looks all through the string for a match. This just looks to see if the beginning of the string matches.
Parameters:
data - string to match
Returns:
a regexp.Result on success, null on failure
See Also:
Result
 o searchForward
  public final Result searchForward(String data,
                                    int offset)
Returns true if the specified String is matched anywhere by this regular expression. This is not like match, which only matches at the beginning of the string. This searches through the whole string starting at the specified offset looking for a match.
Parameters:
data - string to match
Returns:
a regexp.Result on success, null on failure
See Also:
Result
 o searchForward
  public final Result searchForward(char data[],
                                    int offset,
                                    int length)
Returns true if the specified char array is matched anywhere by this regular expression. This is not like match, which only matches at the beginning of the string. This searches through the whole string starting at the specified offset looking for a match.
Parameters:
data - string to match
Returns:
a regexp.Result on success, null on failure
See Also:
Result
 o searchBackward
  public Result searchBackward(String data,
                               int offset)
Returns true if the specified String is matched from the specified offset backward by this regular expression. This is not like match, which only matches at the beginning of the string. This searches through the whole string starting at the specified offset looking for a match.
Parameters:
data - string to match
Returns:
a regexp.Result on success, null on failure
See Also:
Result
 o searchBackward
  public Result searchBackward(char data[],
                               int offset,
                               int length)
Returns true if the specified char array is matched from the specified offset backward by this regular expression. This is not like match, which only matches at the beginning of the string. This searches through the whole string starting at the specified offset looking for a match.
Parameters:
data - string to match
Returns:
a regexp.Result on success, null on failure
See Also:
Result
 o main
  public static void main(String args[]) throws Exception
 o toString
  public final String toString()
Overrides:
toString in class Object
 o toStringThis
  public String toStringThis()

All Packages  Class Hierarchy  This Package  Previous  Next  Index