How to split string using with multiple delimiter in C#

1 Answer

0 votes
using System;

public class Program
{
	public static void Main(string[] args)
	{
		char[] delimiters = { ' ', ',', '.', ':', '\t' };

        string str = "c#\tjava c,c++:go python";

        string[] words = str.Split(delimiters);

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

	}
}




/*
run:
 
c#
java
c
c++
go
python
 
*/

 



answered Nov 30, 2023 by avibootz

Related questions

2 answers 281 views
2 answers 183 views
1 answer 133 views
1 answer 222 views
1 answer 73 views
...