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



JavaScript split()函数

上一篇:php 验证码生成方法 及使用


下一篇:log4net配置详细说明