Use regular to split string

image_pdfimage_print


using System;
using System.Text.RegularExpressions;

class RegexSubstitution
{
   public static void Main()
   {
      string testString1 = "1, 2, 3, 4, 5, 6, 7, 8";
      Regex testRegex1 = new Regex( @"d" );

      Console.WriteLine( "Original string: " + testString1 );

      String[] result = Regex.Split( testString1, @",s" );

      foreach ( string resultString in result )
         Console.WriteLine(""" + resultString + "", ");

   }
}