Separate strings with SPLIT functions

xiaoxiao2021-03-19  192

Using system.text.regularExpressions; // Don't this

1, separated by string:

String str = "aaajsbbbjsccc";

String [] Sarray = regex.split (Str, "JS", regexoptions.ignorecase;

FOREACH (String I in Sarray)

Console.write (I.toTString () "/ n");

Output results:

AAA

BBB

CCC

2, separated by multiple characters: string str = "aaajbbbscccjddddseee"; string [] sarray = str.split (new char [2] {'J', 's'}); Foreach (String i in sarray) Console. Write (i.tostring () "/ n"); output results: AAABBBCCCDDDeee3, separated by single characters: string str = "aaajbbbjccc"; string [] Sarray = Str.Split ('J'); Foreach (String i In Sarray) Console.Write (I.TOString () "/ n"); Output Result: AAABBBCCC

转载请注明原文地址:https://www.9cbs.com/read-130108.html

New Post(0)