<ptml> <pead> <title> String segmentation </title> <script language=javascript> function Getmulti (o ldstr) {var newstr=oldstr;//field content Var i=0,j=0,t=1;//determines whether there is more than one partial content Var foreindex;//record the position of the previous separator var Index,depchar; Record the current separator and its location var linkstr= "";//Link way var astr = new Array (10); var index1 = Newstr.indexof (","); var index2 = Newstr.indexof (";"); var index3 = newstr.indexof ("%"); var index4 = Newstr.indexof (","); var index5 = Newstr.indexof (";"); var index6 = Newstr.indexof (""); function LTrim (str) {for (Var x=0; Str.charat (x) = ""; x + +); Return str.substring (x,str.length); } if (index1!=-1) {index=index1; Depchar= ","; else if (index2!=-1) {index=index2; Depchar= ";";} else if (index3!=-1) {index=index3; depchar= "%"; else if (index4!=-1) {index=index4; Depchar= ","; else if (index5!=-1) {index=index5; Depchar= ";"; else if (index6!=-1) { index=index6; Depchar= ""; } else{T=0;index=-1; Linkstr= "" +newstr+ ""; } foreindex=0; while (index!=-1) {index = Newstr.indexof (Depchar, Foreindex); if (index==foreindex) {foreindex=index+1;continue;} if (index!=-1) {astr[j]=newstr.substring (foreindex,index); Astr[j]=ltrim (Astr[j]); foreindex=index+1; j=j+1; } astr[j]=newstr.substring (Foreindex); if (t==1) {for (i=0;i<j+1;i++) {linkstr=linkstr+ "" +astr[i]+ " "; } return LINKSTR; } </script> </pead> <body> <script language=javascript> var linkstring= ""; var tmpkeyword= "Programmer Software Management software development software complexity software maintenance software model software standard"; Linkstring=getmulti (Tmpkeyword); document.write ("<font color= ' #006699 ' >" +linkstring+ ") </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]