Implementation of Regex.Split() function with comma seperator [Resolved]

Posted by Vasanthmvp under C# on 1/8/2013 | Points: 10 | Views : 1213 | Status : [Member] | Replies : 3
Hi,
Can someone demonstrate me an example how to use Regex.Split() function with comma(,) seperator instead of using string.split(',');
Ex: string x = "This, is, dotnet, funda";
split the above sentence into an array using Regex.Split with comma(,) seperator.

Regards,
Vasanth.

Awesome Coding !! :)


Responses

Posted by: muralikrishnasurap-12704 on: 1/8/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi

string x = "This, is, dotnet, funda";
string[] splitstrings= Regex.Split(x, ",");
foreach (var splitstring in splitstrings)
{
Console.WriteLine(splitstring);
}
Console.Read();

Best Regards
Murali Krishna.S

Vasanthmvp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vasanthmvp on: 1/8/2013 [Member] Starter | Points: 25

Up
0
Down
are you sure..i dont think soo.. have you check it.
without verbatim string literal "@", how can we use it.
And also, my C# developer shows no Split method in Regex.

Regards,
Vasanth Kumar.P

Awesome Coding !! :)

Vasanthmvp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vasanthmvp on: 1/8/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks its working in aspx.cs page's. For complex seperations we use verbatim string literal "@" like
for space - @"\S+";
for non digit = @"\D+"; etc.,

Regards,
Vasanth Kumar.P

Awesome Coding !! :)

Vasanthmvp, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response