Original article: http://blog.csdn.net/szwangdf/article/details/4177104
1. Java
1-1. String Array => string: stringutils: Join (object [] array, string separator)
Example:
/** Join strings using separator >>> AB $ # $ CD $ # $ EF */import Org. apache. commons. lang. stringutils; public class stringutilstrial {public static void main (string [] ARGs) {// join all strings in the array into a single string, // separated by $ # $ system. out. println (stringutils. join (New String [] {"AB", "cd", "Ef"}, "$ # $ "));}}
1-2. String => string array: String: Split (string separator) Example:
Public splitdemo () {string S = "AB $ # $ CD $ # $ EF"; // separate each space character. String [] Ss = S. Split ("$ # $ ");}
2. Javascript
2-1. String Array => string: array: Join (string separator)
Example:
View plain
- <MCE: Script Type ="Text/JavaScript">
- <! --
- VaRA =NewArray ("","B","C");
- A. Join ("|");
- Alert ();
- // -->
- </MCE: SCRIPT>
2-2. String => string array: String: Split (string separator), string: Split (string separator, int length)
Example:
View plain
-
- <MCE: Script Type ="Text/JavaScript">
-
- <! --
-
- VaRSTR ="1234";
-
- VaRStr1 ="Basketball, volleyball, and table tennis";
- VaRArr = Str. Split ("");// Separate all
-
- VaRArr1 = str1.split (",");// Split by comma
-
- VaRArr2 = str1.split (",", 2 );// Split by comma and retain two segments
-
- // -->
-
- </MCE: SCRIPT>