📌  相关文章
📜  将所有单词的第一个字母大写打字稿代码示例

📅  最后修改于: 2022-03-11 14:48:31.238000             🧑  作者: Mango

代码示例1
//Altered, "capitalize all words of a string" (javascript by Grepper on Jul 22 2019) answer to compatible with TypeScript

var myString = 'abcd abcd';

capitalizeWords(text){
  return text.replace(/(?:^|\s)\S/g,(res)=>{ return res.toUpperCase();})
};

console.log(capitalizeWords(myString));

//result = "Abcd Abcd"