Skip to content

StringUtils.splitByWholeSeparator

Signature: StringUtils.splitByWholeSeparator(inputString, separator, max*)

Returns: String[] tokens - an array of parsed Strings, or null if inputString is null

Splits the provided inputString into an array, using whitespace as the separator or the separator specified. The separator is not included in the returned String[]. Adjacent separators are treated as one separator. A null inputString returns null.

Parameters

Type Name Description Default
String inputString the text to split
String separator the string used as the delimiters, null splits on whitespace
Integer max* (optional) the maximum number of elements to include in the array. A zero or negative value implies no limit. 0

Example

var splitArray = StringUtils.splitByWholeSeparator('you and me and max!', 'and');   // ["you "," me ", " max!"]
splitArray = StringUtils.splitByWholeSeparator('The,quick,brown,fox', ',');         // ["The","quick","brown","fox"]