Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

RegExp.prototype[Symbol.split]()

2 tags 1 category

The Symbol.split method of RegExp instances specifies how String.prototype.split should behave when the regular expression is passed in as the separator.

This method exists for customizing the behavior of split() in RegExp subclasses. It is called internally in String.prototype.split() when a RegExp is passed as the separator. For example, the following two examples return the same result.

Like [Symbol.matchAll](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/Symbol.matchAll), Symbol.split starts by using [[Symbol.species]](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/Symbol.species) to construct a new regex, thus avoiding mutating the original regexp in any way. The constructor receives this and the original flags, plus the y (“sticky”) flag if it was not originally present. The g (“global”) flag is irrelevant for the method’s behavior. By default, due to the RegExp() constructor’s behavior, lastIndex starts as 0.

Syntax example: regexp[Symbol.split](str)

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…