Tell us what’s happening:
So I couldn’t complete the challenge as I tried an all regex approach and took a hint.
Could anyone suggest an all regex approach using only split and not replace
Regex i had done :
[_\s]*(?=[A-Z])
But it doesnt match spaces only, without any uppercase character .Any advice?
Your code so far
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
return str.replace(/([a-z])([A-Z])/g, '$1 $2').split(/[\s_]+/g).join("-").toLowerCase();
}
spinalCase('This Is Spinal Tap');
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
.
Link to the challenge: