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
jayakhanna
I don't think something like this is doable in one step... You should do at least one replace besides split...
Andrej
AlexBB
andrej, your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
any ideas
Will George
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
Dark Pontiac
andrej your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
Any ideas
Dhaval Mistry
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
2162
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
ReneeC
Ok, so '/,' is not the splitter... Try this:
string pattern = "\\s*( <=[^/]),\\s*";Andrej
Michelle A.
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
markand
Emadkb
andrej, your latest code gives me this:
john/,smith becomes john/
roger/,wilco becomes roger/
Any ideas
ccrockatt
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
Tryin2Bgood
split into an array is great.
im getting an error on StringSplitOptions.RemoveEmptyEntries
Furqan Farooqui
andreaj your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
Any ideas
Matt Lin
andrej, your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
any ideas