Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年1月.
[Symbol.split]() は RegExp インスタンスのメソッドで、 String.prototype.split にセパレーターとして正規表現が渡されたときにどのように動作するのかを指定します。
分割操作の対象。
limit 省略可検出される分割数の制限を指定する整数。 [Symbol.split]() メソッドは、 this RegExp パターン (または上記の構文では regexp) に一致するたびに、分割項目の数が limit と一致するか、文字列が this パターンを満たなくなるまで、分割を行います。
要素として部分文字列を含む配列 (Array)。
このメソッドは String.prototype.split() において、RegExp がセパレーターとして渡された場合に内部的に呼び出されます。たとえば、次の 2 つの例は同じ結果を返します。
このメソッドは、RegExp のサブクラスで split() の動作をカスタマイズするために存在します。
RegExp.prototype[Symbol.split]() ベースメソッドは、次のように動作します。
this の扱いと引数の並び順を除いて、このメソッドは String.prototype.split() とほとんど同じように使用できます。
既定の動作を修正するために、RegExp のサブクラスで [Symbol.split]() メソッドをオーバーライドできます。
| ECMAScript® 2027 Language Specification # sec-regexp.prototype-%symbol.split% |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年11月10日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.