public class RegexpSplitter extends java.lang.Object implements TextSplitter
implements a TextSplitter
to split text according to a
regular expression.
Modifier and Type | Field and Description |
---|---|
static int |
FETCH
constructor parameter to fetch parts defined by a regular
expression.
|
static int |
SEP
constructor parameter to separate text according to a regular
expression into matching and non-matching parts.
|
static int |
SPLIT
constructor parameter to split text according to a regular
expression.
|
NULLSPLITTER
Constructor and Description |
---|
RegexpSplitter(java.lang.CharSequence re,
int what)
creates a
TextSplitter to split text according the
given regular expression re . |
Modifier and Type | Method and Description |
---|---|
void |
split(TextStore dst,
java.lang.StringBuilder s,
int start)
separates the stretch of text defined by the suffix of
source , starting at start into parts
and stores the parts in dst . |
public static final int SPLIT
public static final int FETCH
public static final int SEP
public RegexpSplitter(java.lang.CharSequence re, int what) throws ReSyntaxException
creates a TextSplitter
to split text according the
given regular expression re
. When split()
is invoked, it will first partition the input string
into matching and non-matching parts. According to parameter
what
these parts are then entered into the TextStore
given to split
:
re
- a regular expression suitable for Nfa
. The
regular expression must not match the empty string.what
- should be one of SPLIT
, FETCH
or
SEP
.ReSyntaxException
- if the given string is not a well
formed regular expressionjava.lang.IllegalArgumentException
- if the given regular expression
matches the empty string.public void split(TextStore dst, java.lang.StringBuilder s, int start)
TextSplitter
separates the stretch of text defined by the suffix of
source
, starting at start
into parts
and stores the parts in dst
.
The method normally does not clear the TextStore
,
but implementations may choose to do so.
Postcondition: Implementations of this method must
treat source
read-only.
split
in interface TextSplitter