Split by Space Capital Letter ou souligner JavaScript
var str = "HelloWorld good_bye";
str = str.split(/[\s_]+|(?=[A-Z])/).join("-");
document.body.innerHTML = str;
Horrible Hedgehog