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
dork
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
VladR
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
tribal
andrej your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
Any ideas
rabbitoh
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
Toni Greco
Ok, so '/,' is not the splitter... Try this:
string pattern = "\\s*( <=[^/]),\\s*";Andrej
Klaus Pr&#252;ckl
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
MichaelDugas
split into an array is great.
im getting an error on StringSplitOptions.RemoveEmptyEntries
Mitesh Shah923
andrej, your latest code gives me this:
john/,smith becomes john/
roger/,wilco becomes roger/
Any ideas
skuehner
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
Tryin2Bgood
I don't think something like this is doable in one step... You should do at least one replace besides split...
Andrej
TRACEYMS
andreaj your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
Any ideas
sawer
ssfftt
andrej, your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
any ideas
ManjuVijay
andrej, your latest code gives me this:
TechRepublic.com
CNET.com
News.com
Builder.com
john/
smith
GameSpot.com
any ideas