Package org.daisy.dotify.common.text
Class StringSplitter
- java.lang.Object
-
- org.daisy.dotify.common.text.StringSplitter
-
public class StringSplitter extends Object
Provides a method for splitting a CharSequence using regex where both matching and non matching sub sequences are retained.
-
-
Constructor Summary
Constructors Constructor Description StringSplitter(String regex)Create a new StringSplitter using the supplied regex.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SplitResult[]split(CharSequence input)Split the input string using the regular expression.static SplitResult[]split(CharSequence input, String regex)Split the input string using the regular expression.static SplitResult[]split(CharSequence input, Pattern pattern)Split the input string using the regular expression.
-
-
-
Constructor Detail
-
StringSplitter
public StringSplitter(String regex)
Create a new StringSplitter using the supplied regex.- Parameters:
regex- the regular expression
-
-
Method Detail
-
split
public static SplitResult[] split(CharSequence input, Pattern pattern)
Split the input string using the regular expression. Similar to thesplitmethod in theStringclass. However, contrary tosplit, all subsequences are returned, even the ones that match. In other words, the input can be reconstructed from the result.- Parameters:
input- the String to splitpattern- the compiled regular expression- Returns:
- returns an array of SplitResults that, if put together, contain all the characters from the input.
-
split
public static SplitResult[] split(CharSequence input, String regex)
Split the input string using the regular expression. Similar to thesplitmethod in theStringclass. However, contrary tosplit, all subsequences are returned, even the ones that match. In other words, the input can be reconstructed from the result.- Parameters:
input- the String to splitregex- the regular expression to use- Returns:
- returns an array of SplitResults that, if put together, contain all the characters from the input.
-
split
public SplitResult[] split(CharSequence input)
Split the input string using the regular expression. Similar to thesplitmethod in theStringclass. However, contrary tosplit, all subsequences are returned, even the ones that match. In other words, the input can be reconstructed from the result.- Parameters:
input- the String to split- Returns:
- returns an array of SplitResults that, if put together, contain all the characters from the input.
-
-