我在javascript中遇到数组问题。我有这样的数组:当字符为大写字符时的子串数组元素
Subjects[]:
[0] = 'Introduction to interesting things'
[1] = 'Cats and dogs'
[2] = 'I can't believe it's not butter Á machine lord'
[3] = 'I Intergalactic proton powered advertising droids '
正如你所看到的,在科目[2],有2串
'I can't believe it's not butter' and 'Á machine lord'
此外,在主题[3],将字符串 'I' 开始,这应该是
'Á machine lord I'.
有没有办法削减大写的字符串开始并创建一个新的索引的字符串?像这样:
Subjects[]:
[0] = 'Introduction to interesting things'
[1] = 'Cats and dogs'
[2] = 'I can't believe it's not butter'
[3] = 'Á machine lord I'
[4] = 'Intergalactic proton powered advertising droids'
我试过用.split
没有成功。任何帮助将是有用的。
最简单的方法:经过串。检查当前单词是否有大写起始符号。检查下一个单词是否有大写起始符号。如果你回答第一个问题是肯定的,第二个问题回答是否定的,分裂。在字符串的末尾重复,直到字符串为空。 – Zeta