どうも、ちょげ(@chogetarou)です。
文字列(string)を正規表現で分割する方法を紹介します。
方法

文字列(string)を正規表現で分割するには、split()を使います。
まず、文字列からsplit()を呼び出します。
そして、split()の引数に正規表現を指定します。
const result = text.split(/正規表現/オプション);
上記のsplit()は、引数に指定した正規表現で呼び出した文字列を分割します。
使用例
const text = "A0BC1DEF2GH3IJK";
const result = text.split(/[0-9]/);
console.log(result);
出力:
[ 'A', 'BC', 'DEF', 'GH', 'IJK' ]
コメント