dice()

Dices up a string splitting it on the passed in delimiter and placing the results in an array while making sure that the empty string is converted to an empty array.

This function is valid in v2.1.0 to v2.12.0. This function has been downloaded 10 times.

Parameters

{string} str
The string to be diced and turned into an array of strings.
{RegExp|string} delim
The regular expression or string to be used as a delimiter in order to dice up str. The matched substrings will not be included in the strings returned in the array.
{number=} opt_limit Optional, Default:Infinity
If specified, this number represents the maximum number of times str will be split on delim. Unlike with String.prototype.split(), the remaining substring after this limit will simply be placed in the last element of the array.

Returns

{Array.<string>}
Returns an array of substrings formed by dicing (splitting) up str by delim. If str is an empty string, an empty array will be returned.

Required Functions

This function requires the following functions which are included automatically:

  • modRegExp()
    Creates a new copy of a regular expression with modified flags.
  • quoteRegExp()
    Turn any string into a regular expression that matches the exact string without worrying about encoding the metacharacters yourself.
  • typeOf()
    Either gets the type of a value or adds a constructor registering its custom type name.