The use of split is summarized as follows: 1. Single Character Segmentation: String S = abcdeabcdeabcde;
String [] sarray = S. Split (C );
Foreach (string I in sarray)
Console. writeline (I. tostring ());
Output the following results:
AB
Deab
Deab
De2. use a constructor to separate multiple characters: String S = abcdeabcdeabcde;
String [] sarray = S. Split (New char (3) {c, d, e });
Foreach (string I in sarray)
Console. writeline (I. tostring (); output the following result: AB
AB
AB
Note: In the constructor new char (3) {c, d, e}, if it is to be separated by spaces or non-characters, must be enclosed in single quotes, such as new char () {''}; 3. first ProgramTo reference the Assembly related to the regular expression: using system. Text. regularexpression; then use the following method: String content = agcsmallmacsmallgggsmall Ytx;
String [] resultstring = system. Text. regularexpression_rs. RegEx. Split (content, small, regexoptions. ignorecase)
Foreach (string I in resultstring)
Console. writeline (I. tostring ());
Output the following results:
AGC
Mac
Ggg
Ytx Summary: these methods are commonly used for 1, 2, and 2, and 3rd can also achieve the corresponding effect. If you are familiar with the regular expression, you may also use 3rd methods.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service