appended to the result array. Then, the capturing groups' values are appended one-by-one. 
  * If the current match is an empty string, or if the regexp doesn't match at the current position (since it's sticky), the ` lastIndex ` would still be advanced â if the regex is [ Unicode-aware ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode#unicode-aware_mode) , it would advance by one Unicode code point; otherwise, it advances by one UTF-16 code unit. 
  * If the regexp doesn't match the target string, the target string is returned as-is, wrapped in an array. 
  * The returned array's length will never exceed the ` limit ` parameter, if provided, while trying to be as close as possible. Therefore, the last match and its capturing groups may not all be present in the returned array if the array is already filled. 

##  Examples

###  Direct call

This method can be used in almost the same way as [ ` String.prototype.split()
` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) , except
the different ` this ` and the different order of arguments.

js

    
    
    const re = /-/g;
    const str = "2016-01-02";
    const result = re[Symbol.split](str);
    console.log(result); // ["2016", "01", "02"]
    

###  Using @@split in subclasses

Subclasses of [ ` RegExp ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) can override the `
[@@split]() ` method to modify the default behavior.

js

    
    
    class MyRegExp extends RegExp {
      [Symbol.split](str, limit) {
        const result = RegExp.prototype[Symbol.split].call(this, str, limit);
        return result.map((x) => `(${x})`);
      }
    }
    
    const re = new MyRegExp("-");
    const str = "2016-01-02";
    const result = str.split(re); // String.prototype.split calls re[@@split].
    console.log(result); // ["(2016)", "(01)", "(02)"]
    

##  Specifications

Specification  
---  
[ ECMAScript Language Specification  
#  sec-regexp.prototype-@@split  ](https://tc39.es/ecma262/multipage/text-
processing.html#sec-regexp.prototype-@@split)  
  
##  Browser compatibility

BCD tables only load in the browser  with JavaScript enabled. Enable
JavaScript to view data.

##  See also

  * [ Polyfill of ` RegExp.prototype[@@split] ` in ` core-js ` ](https://github.com/zloirock/core-js#ecmascript-string-and-regexp)
  * [ ` String.prototype.split() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
  * [ ` RegExp.prototype[@@match]() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match)
  * [ ` RegExp.prototype[@@matchAll]() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@matchAll)
  * [ ` RegExp.prototype[@@replace]() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@replace)
  * [ ` RegExp.prototype[@@search]() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@search)
  * [ ` RegExp.prototype.exec() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)
  * [ ` RegExp.prototype.test() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test)
  * [ ` Symbol.split ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split)

##  Help improve MDN

Was this page helpful to you?

Yes  No

[ Learn how to contribute
](https://github.com/mdn/content/blob/main/CONTRIBUTING.md "This will take you
to our contribution guidelines on GitHub.") .

This page was last modified on  Jun 22, 2023  by  [ MDN contributors ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@split/contributors.txt)
.

[ View this page on GitHub
](https://github.com/mdn/content/blob/main/files/en-
us/web/javascript/reference/global_objects/regexp/@@split/index.md?plain=1
"Folder: en-us/web/javascript/reference/global_objects/regexp/@@split \(Opens
in a new tab\)") â¢  [ Report a problem with this content
](https://github.com/mdn/content/issues/new?template=page-report.yml&mdn-
url=https%3A%2F%2Fdeveloper.mozilla.org%2Fen-
US%2Fdocs%2FWeb