JSFiddle - React, Tailwind, and code Playground
JavaScript
var str = 'Split on spaces, except "for this", and \'this section\', and `ignore this too`.';
var replacedStr = str.replace(/(\S*(?:(['"`]).*?\2)\S*)\s?|\s/g, "$1<br>");
document.write(replacedStr);