【发布时间】:2014-09-30 08:38:53
【问题描述】:
例如如果我运行这个 javascript:
var str = 'hello_world_there';
var parts = str.split('_', 2);
var p1 = parts[0];
var p2 = parts[1];
最后,p1 包含“hello”,p2 包含“world”。
我希望 p1 包含“hello”,p2 包含“world_there”。即我希望 p2 包含字符串的其余部分,无论它有多少下划线(类似于 c# 的 String.Split(char[] separator, int count) 的行为方式。
任何解决方法?
【问题讨论】:
标签: javascript string split