Link to home
Start Free TrialLog in
Avatar of Member_2_99151
Member_2_99151

asked on

How can I split a Quoted String?

Hi all,

I have a string similar to this:
"1.1.1" "2.2.2 Possibly Some Info Here" "3.3.3 And Maybe Some Info Here Too!"

I would like the array to be
1.1.1
2.2.2 Possibly Some Info Here
3.3.3 And Maybe Some Info Here Too!

Looks like C# (2005) has no native way to do this (unless I am lissing something.

Any ideas how this can be achieved?

Thanks,

James
ASKER CERTIFIED SOLUTION
Avatar of Avodah
Avodah
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Member_2_99151
Member_2_99151

ASKER

Hi,
These both almost work..
DaTribe, if there is more than one space between the delimited items, the delimeter does not match :-(
kaylanreilor, you get blank lines in the returned array (the space(s) delimiting the string.

I can mod the result to remove the blank lines, but is there a more direct way; maybe a regex split?
It is because you have whitespaces between '"' in your original string. You cannot remove them since it will remove the necessary whitespaces. So I suppose that you remove afterward in the array.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks everyone for all the suggestions.
As there are several great solutions, I feel it would be right to split the points in this case - hope this is ok with everyone.
James