1, Java1-1. Array of strings = =string: Stringutils:join (object[] array, string separator) Example: Java Code Collection CodeImportorg.apache.commons.lang.StringUtils; Public classstringutilstrial { Public Static voidMain (string[] args) {//Join all Strings in the Array to a single String,//separated by $#$System.out.println (Stringutils.join (NewString[] {"AB", "CD", "EF"}, "$#$")); } } 1-2. String = =string array: String:split (String separator) Example: Java Code Collection Code PublicSplitdemo () {String s= "ab$# $CD $# $EF"; //decompose at each space character. string[] ss = S.split ("$#$"); } 2, JavaScript2-1. Array of strings = =string: Array:join (String separator) Example: JS Code Collection Code<mce:script type= "Text/javascript" > <!--var a=NewArray ("A", "B", "C"); A.join ("|"); alert (a); // -</mce:script> 2-2, String = string array: String:split (String separator), String:split (string separator,intlength) Example: JS Code Collection Code<mce:script type= "Text/javascript" > <!--var str= "1234"; var str1= "basketball, volleyball, table tennis"; var arr= Str.split ("");//Split Allvar arr1 = Str1.split (",");//Split by commavar arr2 = Str1.split (",", 2);//two segments are retained according to comma division// -</mce:script>
Cross-transfer between string array and string (Join/split)