課題
正規表現の<form></form>
の部分を変数に置換したいのですが、
うまくいきません。
const str = '<p>hoge</p><form></form><span>hoge</span><form></form><section>hoge</section>' const arr = str.split(/(<form></form>)/); console.log(arr); // [ '<p>hoge</p>', // '<form></form>', // '<span>hoge</span>', // '<form></form>', // '<section>hoge</section>' ]
試していること
const HOGE = '<form></form>'; const str = '<p>hoge</p><form></form><span>hoge</span><form></form><section>hoge</section>' const arr = str.split(/(HOGE)/); console.log(arr);
正規表現中のHOGE
をなんらかの記号でラップする必要がある気はするのですが、
もしご存知のかたいらっしゃったらよろしくお願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。