How to extract all words from a string by multiple delimiters in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string str = "java,c++.c|python:c#?php=javascript";    
          
        char[] delimiters = new Char[] { ',', '.', '|', ':', '=', '?' };

        string[] arr = str.Split(delimiters);
        
        foreach (string s in arr) {
           Console.WriteLine(s);
        }
    }
}





/*
run:

java
c++
c
python
c#
php
javascript

*/


 



answered Apr 11, 2022 by avibootz
...