日期:2014-05-16 浏览次数:20526 次
function splitTest0530(){
var colors = "red,blue,green,yellow";
var colors1 = colors.split(",");
var colors2 = colors.split("," , 2);
var colors3 = colors.split(/[^\,]+/);
return "colors1:" + colors1 + "\nlength=" + colors1.length + "\n"
+ "colors2:" + colors2 + "\nlength=" + colors2.length + "\n"
+ "colors3:" + colors3 + "\nlength=" + colors3.length + "\n";
}
<input type=button value =alertColors onclick=alert(splitTest0530()) />