Split into multiple characters

Execution result

var b = "asfsadefbweabgggggggggggg".Split("ab".ToCharArray());

is a list of 6 lines, while I want to split the array in "asfsadefbwe"and "gggggggggggg". Is there a way / way to do this correctly (with C #)?

PS: I will use a string that has some data separately "\r\n"secuences.

+5
source share
3 answers
string[] list = b.Split(new string[] { "ab" }, StringSplitOptions.None);
+21
source

Use a different overload that is not split into separate characters:

 "asfsadefbweabgggggggggggg".Split(new [] {"ab" }, StringSplitOptions.None)
+12
source

Are your substrings the same length? If so, use String.Substring .

0
source

All Articles