如何通过js将所有字符和大写字母仅包含在第一个字符中?(How to downcase all char and uppercase only the first characters via js? [duplicate])
这个问题在这里已有答案:
如何在JavaScript中创建字符串大写的第一个字母? 75个答案现在我有这个正则表达式: tSzoveg = tSzoveg.replace(/\b[AZ]{2,}\b/,'');
这几乎就是我想要的。 我想转换一下: THIS IS MINE, NOT YOURS. 对此: This is mine, not yours.
如何将其转换为正常句子?
This question already has an answer here:
How do I make the first letter of a string uppercase in JavaScript? 83 answersNow I have this regex: tSzoveg = tSzoveg.replace(/\b[A-Z]{2,}\b/,'');
It is almost that I want. I want to convert this: THIS IS MINE, NOT YOURS. to this: This is mine, not yours.
How can I convert it to a normal sentence?
最满意答案
我会使用toLowerCase()然后修改第一个字母:
var str = "THIS IS MINE, NOT YOURS." str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();I would use toLowerCase() and then modify the first letter:
var str = "THIS IS MINE, NOT YOURS." str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();更多推荐
发布评论