Several Methods to separate strings are summarized as needed:
1. Separated by strings:
Using system. Text. regularexpressions;
String STR = "aaajsbbbjsccc ";
String [] sarray =RegEx. Split(STR, "JS ",Regexoptions. ignorecase);
Foreach (string I in sarray) response. Write (I. tostring () + "<br> ");
Output result:
Aaa
Bbb
CCC
2. Separate multiple characters:
String STR = "aaajbbbscccjdddseee ";
String [] sarray = Str. Split (New char [2] {'J','s '});
Foreach (string I in sarray) response. Write (I. tostring () + "<br> ");
Output result:
Aaa
Bbb
CCC
Ddd
Eee
3. Separate them with a single character:
String STR = "aaajbbbjccc ";
String [] sarray = Str. Split ('J');
Foreach (string I in sarray) response. Write (I. tostring () + "<br> ");
Output result:
Aaa
Bbb
CCC
---------------------------------------------
However, if you have any questions, you may wish to learn the following:
the string separator string mentioned in the "1" method, if "JS" is used to separate "aaajsbbbjsccc", it can be normally separated, however, you cannot use "^ * ^" to separate "AAA ^ * ^ BBB ^ * ^ CCC, the output result is still "AAA ^ * ^ BBB ^ * ^ CCC". I don't know how to solve this problem. Ask! Thank you!