gpt4 book ai didi

javascript - 在javascript中将字符串转换为句子大小写

转载 作者:搜寻专家 更新时间:2023-11-01 04:44:56 26 4
gpt4 key购买 nike

我希望输入的字符串无论大小写都应转换为句子大小写。

喜欢

hi all, this is derp. thank you all to answer my query.

转换为

Hi all, this is derp. Thank you all to answer my query.

最佳答案

我想出了这种正则表达式:

var rg = /(^\w{1}|\.\s*\w{1})/gi;
var myString = "hi all, this is derp. thank you all to answer my query.";
myString = myString.replace(rg, function(toReplace) {
return toReplace.toUpperCase();
});

关于javascript - 在javascript中将字符串转换为句子大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19089442/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com