📌  相关文章
📜  javascript 字符串正确大小写 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:16.584000             🧑  作者: Mango

代码示例4
function toTitleCase(str) {
  return str.replace(
    /\w\S*/g,
    function(txt) {
      return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    }
  );
}
// example
toTitleCase("the pains and gains of self study");
// "The Pains And Gains Of Self Study"