Application of split separator strings in Asp.net

Source: Internet
Author: User
1. Introduce namespace
Using system. Text. regularexpressions;
Ii. Instances 1 /**/ ///1. Separated by strings:
2
3 Using System. Text. regularexpressions;
4
5
6 String Str = " Aaajsbbbjsccc " ;
7
8
9 String [] Sarray = RegEx. Split (STR, " JS " , Regexoptions. ignorecase );
10
11
12 Foreach ( String I In Sarray) response. Write (I. tostring () +   " <Br> " );
13
14
15
16
17 Output result:
18 Aaa
19 Bbb
20 CCC
21
22
23
24 /**/ ///2. Separate multiple characters:
25
26
27 String Str = " Aaajbbbscccjdddseee " ;
28
29
30 String [] Sarray = Str. Split ( New   Char [ 2 ] {'J','S'} );
31
32
33 Foreach ( String I In Sarray) response. Write (I. tostring () +   " <Br> " );
34
35
36
37
38 /**/ ///Output result:
39 Aaa
40 Bbb
41 CCC
42 Ddd
43 Eee
44
45
46
47 /**/ ///3. Separate them with a single character:
48
49
50 String Str = " Aaajbbbjccc " ;
51
52
53 String [] Sarray = Str. Split ( ' J ' );
54
55
56 Foreach ( String I In Sarray) response. Write (I. tostring () +   " <Br> " );
57
58 Output result:
59 Aaa
60 Bbb
61

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.