hi,
im using c#, have a comma delimited string and i wish to split it.
string example is:
john smith, freddy, mark/,jones, john
i don't wish to split where a comma is backslashed.
any ideas thanks.
hi,
im using c#, have a comma delimited string and i wish to split it.
string example is:
john smith, freddy, mark/,jones, john
i don't wish to split where a comma is backslashed.
any ideas thanks.
extracting data from comma delimited string
Timski72
andrej your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
Any ideas
kymaita
andrej, your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
any ideas
Frank Carr
I don't think something like this is doable in one step... You should do at least one replace besides split...
Andrej
jocuppens
Ok, so '/,' is not the splitter... Try this:
string pattern = "\\s*( <=[^/]),\\s*";Andrej
SteinerA
andrej, your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
any ideas
Dhandapani
andrej, your latest code gives me this:
john/,smith becomes john/
roger/,wilco becomes roger/
Any ideas
St&#233;phane Beauchemin
split into an array is great.
im getting an error on StringSplitOptions.RemoveEmptyEntries
kennm
vsarowatz
You're probably using .NET framework 1.x then... You can try without it, but the result would include empty array items... I'll look into your regex expression...
Andrej
TarPista
i have the following code but it splits where a comma is backslashed which i don't want.
string
values = "TechRepublic.com, CNET.com, News.com, Builder.com, john/, smith, GameSpot.com"; string pattern = ",( =( :[^\"]*\"[^\"]*\")*( ![^\"]*\"))";System.Text.RegularExpressions.Regex r =
new Regex(pattern); string[] sites = r.Split(values);any ideas
hapazlam
andreaj your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
Any ideas
Ruprect8696
How about something like this...:
string values = "TechRepublic.com, CNET.com, News.com, Builder.com, john/, smith, GameSpot.com";string pattern = "\\s*,\\s*";
System.Text.RegularExpressions.Regex r = new Regex(pattern);
string[] sites = r.Split(values);
Andrej
Rob Mijnen
TechRepublic.com
CNET.com
News.com
Builder.com
john/, smith
GameSpot.com
getting better, how do i remove the backslash
Thanks for your time andrej
white2grey
Hi,
you didn't write how you want your string to be split... anyway, how about this piece of code...:
string values = "TechRepublic.com, CNET.com, News.com, Builder.com, john/, smith, GameSpot.com";string[] arrayOfValues = values.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
Andrej