我有一个这样的字符串:
RegexMy RegexGoodregexNo need for Regex
怎么拆分成这样?
Regex, My Regex, Goodregex, No need for Regex
我的尝试并没有真正奏效,因为它也在空格后 split :
var tmp = ("RegexMy RegexGoodregexNo need for Regex").split(/(?=[A-Z])/);
最佳答案
以下似乎工作正常:
'RegexMy RegexGoodregexNo need for Regex'.replace(/(\S)([A-Z])/g, '$1, $2');
// "Regex, My Regex, Goodregex, No need for Regex"
关于javascript - 拆分每个大写字母,除非它前面有空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23105772/