Use Regular Expressions to split string : Regular Expression : Regular Expression C# Examples


C# Examples » Regular Expression » Regular Expression »

 

Use Regular Expressions to split string









    
using  System;
using  System.Text.RegularExpressions;

class  MainClass
{
        public  static  void  Main()
        {
                string  s  =  "A,  B,cCCC,  D";
                Regex  regex  =  new  Regex(@"  |,  ");
                foreach  (string  sub  in  regex.Split(s))
                {
                        Console.WriteLine("Word:  {0}",  sub);
                }
        }
}
    
   
  
   



Output

Word: A
Word: B,cCCC
Word: D


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Regular Expression
» Regular Expression