Module: deserializeValue

module:deserializeValue

Splits a string into an array of strings using a regex or string separator. Matches of the separator are not included in the result array. However, if `separator` is a regex that contains capturing groups, backreferences are spliced into the result each time `separator` is matched. Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably cross-browser.
Parameters:
Name Type Attributes Description
str String String to split.
separator RegExp | String Regex or string to use for separating the string.
limit Number <optional>
Maximum number of items to include in the result array.
Source:
Returns:
Array of substrings.
Type
Array
Example
// Basic use
split('a b c d', ' ');
// -> ['a', 'b', 'c', 'd']

// With limit
split('a b c d', ' ', 2);
// -> ['a', 'b']

// Backreferences in result array
split('..word1 word2..', /([a-z]+)(\d+)/i);
// -> ['..', 'word', '1', ' ', 'word', '2', '..']