gpt4 book ai didi

javascript - JavaScript 中字符串中小写字母和大写字母之间的空格

转载 作者:数据小太阳 更新时间:2023-10-29 04:55:03 25 4
gpt4 key购买 nike

我想在一个字符串中的小写字母和大写字母之间添加一个空格。例如:

FruityLoops
FirstRepeat

现在我想在小写字母和大写字母之间添加一个空格。我不知道我应该如何开始使用 JavaScript。带有 substr 或搜索的东西?有人可以帮助我吗?

最佳答案

var str = "FruityLoops";

str = str.replace(/([a-z])([A-Z])/g, '$1 $2');

示例: http://jsfiddle.net/3LYA8/

关于javascript - JavaScript 中字符串中小写字母和大写字母之间的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4819829/

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