Join/split)
1. Java
1-1. String Array => string: stringutils: Join (object [] array, string separator)
Example:/* <Br/> * join strings using separator> AB $ # $ CD $ # $ EF <br/> */</P> <p> Import Org. apache. commons. lang. stringutils; </P> <p> public class stringutilstrial {<br/> Public static void main (string [] ARGs) {</P> <p> // join all strings in the array into a single string, <br/> // separated by $ #$ <br/> system. out. println (stringutils. join (<br/> New String [] {"AB", "cd", "Ef"}, "$ # $ ")); <br/>}< br/>}
1-2. String => string array: String: Split (string separator)
Example:Public splitdemo () {<br/> string S = "AB $ # $ CD $ # $ EF"; <br/> // separate each space character. <Br/> string [] Ss = S. Split ("$ # $"); <br/>}
2. Javascript
2-1. String Array => string: array: Join (string separator)
Example:<MCE: Script Type = "text/JavaScript"> <br/> <! -- <Br/> var A = new array ("A", "B", "C"); <br/>. join ("|"); <br/> alert (a); <br/> // --> <br/> </MCE: SCRIPT>
2-2. String => string array: String: Split (string separator), string: Split (string separator, int length)
Example:<MCE: Script Type = "text/JavaScript"> <br/> <! -- <Br/> var STR = "1234"; <br/> var str1 = "basketball, volleyball, and table tennis"; <br/> var arr = Str. split (""); // all split <br/> var arr1 = str1.split (","); // split by comma <br/> var arr2 = str1.split (",", 2); // split by comma, retain two segments <br/> // --> <br/> </MCE: SCRIPT>