JSFiddle - React, Tailwind, and code Playground
HTML
<div id='results'></div>
JavaScript
var strs =
[ 'thisStringIsGood'
, 'somethingLikeThis'
, 'a123CapsHere345AndHEREButNOT678Here90End'
, '123CapsHere345AndHEREButNOT678Here90e'
];
function capSplit(str){
return str.replace
( /(^[a-z]+)|[0-9]+|[A-Z][a-z]+|[A-Z]+(?=[A-Z][a-z]|[0-9])/g
, function(match, first){
if (first) match = match[0].toUpperCase() + match.substr(1);
return match + ' ';
}
)
}
for (var str in strs)
if (strs.hasOwnProperty(str))
document.getElementById('results').innerHTML += capSplit(strs[str]+"<br>");