This article mainly introduces the use of ASP.net string segmentation function, the need for friends can refer to the following
Let's take a look at a simple example but its array length is 25 instead of 3. The following approach is to first replace "[Jb51.net]" with a special character, such as $, which performs a split based on this character, such as the following according to [Jb51.net] split code as follows: string[] arrstr2 = str. Replace ("[Jb51.net]", "$"). Split (' $ '); Look at other methods, the simplest and most commonly used methods, split with a specified character open vs.net create a new console project. Then enter the following program under the main () method. Code as follows: String s= "ABCDEABCDEABCDE"; string[] sarray=s.split (' C '); foreach (String i in Sarray) & nbsp Console.WriteLine (i.ToString ()); Output The following results: code as follows: ab deab deab de 2, split with multiple characters The code is as follows: String s= "ABCDEABCDEABCDE" string[] sarray1=s.split (new char[3]{' C ', ' d ', ' e '}); foreach (String i in SArray1) Console.WriteLine (i.ToString ()); Output The following results: code as follows: ab ab AB 3, use regular expression Add reference code as follows: using System.Text.RegularExpressions; String content= "Agcsmallmacsmallgggsmallytx"; string[]resultstring=regex.split (Content, "small", Regexoptions.ignorecase) foreach (String i in Resultstring) Console.WriteLine (i.ToString ()); Output The following results: code as follows: agc mac ggg ytx There is a less common method of the code as follows: String str = "Reterry[jb51.net]" is the webmaster of the Script House [jb51.net]; string[] arrstr = str. Split (new char[] {', ' s ', ' o ', ' s ', ' u ', ' O ', ' 8 ', '. ', ' C ', ' O ', ' m ', ', '} '; for (int i = 0; i < Arrstr. Length; i++) { Response.Write (Arrstr[i]); }