Did a quick try and my final code does this (pseudocode):
Add space before each capital letter.
Change string to lowercase.
Replace non-letters with space.
Trim spaces (strings have such method).
Replace spaces with dashes.
There are ninjas who can write one line regexes, but I’m not one of them
I updated your code. Here is my solution for the problem.
function spinalCase(str) {
var re = /(\ba-z)/g;
str = str.replace(re, function(x){return x.toUpperCase();});
var regex = /[-_+ |\s+]/g;
str = str.replace(regex, “”);
str = str.replace(/[A-Z]/g, function(match, offset) {
return (offset ? ‘-’ : ‘’) + match.toLowerCase();
});