JavaScript split()函数

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript split()函数</title>
<script type="text/javascript">
    var str = "http://blog.csdn.net/you23hai45/article/details/19048383";
    document.write(str.split(".", 2));
	document.write("<br>");
	document.write(str.split("."));
	document.write("<br>");
    document.write(str.split(""));
	document.write("<br>");
    document.write(str.split("", 3));
	var subStr = "-http-www-blog-";
	document.write(subStr.split("-"));
	var youStr = "you,hai,dong,1,2,3,4,5,6,78,89";
	var youStrs = new Array();
	youStrs = youStr.split(",");
	for(var i=0;i<youStrs.length;i++)
	{
		 document.write(youStrs[i]);
	     document.write("<br>");
	}
</script>
</head>

<body>
</body>
</html>

结果:

http://blog,csdn
http://blog,csdn,net/you23hai45/article/details/19048383
h,t,t,p,:,/,/,b,l,o,g,.,c,s,d,n,.,n,e,t,/,y,o,u,2,3,h,a,i,4,5,/,a,r,t,i,c,l,e,/,d,e,t,a,i,l,s,/,1,9,0,4,8,3,8,3
h,t,t,http,www,blog,you
hai
dong
1
2
3
4
5
6
78
89



郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。