Spinal Tap Case

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  str = str.replace(/_/g," ")
        .replace(/([A-Z])/g," $1")
        .replace(/^s/,"")
        .replace(/s+/g,"-")
        .toLowerCase();
  return str;
}
spinalCase('This Is Spinal Tap');

  

原文地址:https://www.cnblogs.com/mengruying/p/6198611.html