Javascript Regex Split

javascript-regex

The [@@split]() method splits a String object into an array of strings by 
separating the string into substrings.

regexp[Symbol.split](str[, limit])

1. str: The target of the split operation.
2. limit: Optional. Integer specifying a limit on the number of splits to be found.

'a-b-c'.split(/-/);
/-/[Symbol.split]('a-b-c');

var re = /-/g;
var str = '2016-01-02';
var result = re[Symbol.split](str);
console.log(result);  // ["2016", "01", "02"]
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License