|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--starwave.util.regexp.Regexp
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 Summary | |
static Regexp |
compile(java.lang.String expr)
|
static Regexp |
compile(java.lang.String expr,
boolean mapCase)
Return a compiled regular expression. |
static void |
main(java.lang.String[] args)
|
Result |
match(char[] data,
int offset,
int length)
Returns true if the specified String is matched by this regular expression. |
protected boolean |
match(starwave.util.regexp.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. |
Result |
match(java.lang.String data,
int offset)
Returns true if the specified String is matched by this regular expression. |
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. |
Result |
searchBackward(java.lang.String data,
int offset)
Returns true if the specified String is matched from the specified offset backward by this regular expression. |
Result |
searchForward(char[] data,
int offset,
int length)
Returns true if the specified char array is matched anywhere by this regular expression. |
Result |
searchForward(java.lang.String data,
int offset)
Returns true if the specified String is matched anywhere by this regular expression. |
java.lang.String |
toString()
|
java.lang.String |
toStringThis()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public static Regexp compile(java.lang.String expr)
public static Regexp compile(java.lang.String expr, boolean mapCase)
protected boolean match(starwave.util.regexp.State state)
public Result match(java.lang.String data, int offset)
data
- string to match
Result
public Result match(char[] data, int offset, int length)
data
- string to match
Result
public final Result searchForward(java.lang.String data, int offset)
data
- string to match
Result
public final Result searchForward(char[] data, int offset, int length)
data
- string to match
Result
public Result searchBackward(java.lang.String data, int offset)
data
- string to match
Result
public Result searchBackward(char[] data, int offset, int length)
data
- string to match
Result
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public final java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringThis()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |