How to split a string on array of strings in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string str = "Echo==Cora==Katniss...Xavier...Spock";

        string[] array = { "==", "..." };
        
        string[] words = str.Split(array, System.StringSplitOptions.RemoveEmptyEntries);

        foreach (string word in words) {
            Console.WriteLine(word);
        }
    }
}




/*
run:

Echo
Cora
Katniss
Xavier
Spock

*/

 



answered Aug 7, 2022 by avibootz
...