C# Program to Split a string having characters like ;/?.,- in between using Replace and split

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 307


using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
new Regex("[;/?.,-]")
.Replace("niladri,arina/biswas?babai;RNA.Team-We All Are Same -Is not it?Yes it is", "~") //replacing with tilde
.Split('~') //split with tilde
.ToList()
.ForEach(i => Console.WriteLine(i));

Console.ReadKey();

}
}
}



Result
-------

niladri
arina
biswas
babai
RNA
Team
We All Are Same
Is not it
Yes it is

Comments or Responses

Login to post response