public final class StringSplitUtils
extends java.lang.Object
String
manipulation methods.Modifier and Type | Method and Description |
---|---|
static java.lang.String[] |
split(java.lang.String toSplit,
java.lang.String delimiter)
Splits a
String at the first instance of the delimiter. |
static java.util.Map |
splitEachArrayElementAndCreateMap(java.lang.String[] array,
java.lang.String delimiter,
java.lang.String removeCharacters)
Takes an array of
String s, and for each element removes any instances of
removeCharacter , and splits the element based on the delimiter . |
static java.lang.String[] |
splitIgnoringQuotes(java.lang.String str,
char separatorChar)
Splits a given string on the given separator character, skips the contents of quoted substrings
when looking for separators.
|
static java.lang.String |
substringAfterLast(java.lang.String str,
java.lang.String separator) |
static java.lang.String |
substringBeforeLast(java.lang.String str,
java.lang.String separator) |
public static java.lang.String[] split(java.lang.String toSplit, java.lang.String delimiter)
String
at the first instance of the delimiter.Does not include the delimiter in the response.
toSplit
- the string to splitdelimiter
- to split the string up withjava.lang.IllegalArgumentException
- if an argument was invalidpublic static java.util.Map splitEachArrayElementAndCreateMap(java.lang.String[] array, java.lang.String delimiter, java.lang.String removeCharacters)
String
s, and for each element removes any instances of
removeCharacter
, and splits the element based on the delimiter
. A Map
is
then generated, with the left of the delimiter providing the key, and the right of the delimiter providing the
value.Will trim both the key and value before adding to the Map
.
array
- the array to processdelimiter
- to split each element using (typically the equals symbol)removeCharacters
- one or more characters to remove from each element prior to attempting the split
operation (typically the quotation mark symbol) or null
if no removal should occurMap
representing the array contents, or null
if the array to process was
null or emptypublic static java.lang.String substringBeforeLast(java.lang.String str, java.lang.String separator)
public static java.lang.String substringAfterLast(java.lang.String str, java.lang.String separator)
public static java.lang.String[] splitIgnoringQuotes(java.lang.String str, char separatorChar)