Jer*_*ohn 1 javascript string split
我有这个字符串
var str = "394987011016097814 1d the quick brown fox jumped over the lazy dog";
Run Code Online (Sandbox Code Playgroud)
..而我正试图让它成为这个阵列
[
"394987011016097814",
"1d",
"the quick brown fox jumped over the lazy fox",
]
Run Code Online (Sandbox Code Playgroud)
我已经看到这个答案在第一个空白区域出现分裂字符串,但这仅适用于第一个空格.
使用拆分和连接进行结构化
var str = "394987011016097814 1d the quick brown fox jumped over the lazy fox";
var [str1, str2, ...str3] = str.split(' ');
str3 = str3.join(' ');
console.log([str1, str2, str3])Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
92 次 |
| 最近记录: |