JSFiddle - React, Tailwind, and code Playground
JavaScript
let str = '<!-- Button --><div><button></div><!-- Input --><input type="text">';
alert(str.split(/<!--[\s\w]*-->/g).filter(n => n));
let str = '<!-- Button --><div><button></div><!-- Input --><input type="text">';
alert(str.split(/<!--[\s\w]*-->/g).filter(n => n));