新手拆分字符串问题
"11-dasdasdsd-ffd-ee-22 "
像以上的字符串怎么样拆分成
11
dasdasdsd
ffd
ee
22
------解决方案-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>
<BODY>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
var str = "11-dasdasdsd-ffd-ee-22 ";
var strArray = new Array();
strArray = str.split( "- ");
var i;
for(i=0;i <strArray.length;i++) {
alert(strArray[i]);
}
//-->
</SCRIPT>
</BODY>
</HTML>
------解决方案--------------------var ar = "11-dasdasdsd-ffd-ee-22 ".split( "- ");
or
var ar = "11-dasdasdsd-ffd-ee-22 ".match(/[^\-]+/g);
------解决方案-------------------- <script>
var str= "11-dasdasdsd-ffd-ee-22 ";
var arr=new Array()
arr=str.split( "- ");
for (var i=0;i <arr.length ;i++ )
{
document.write(arr[i]+ " <br/> ");
}
</script>