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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
ASKER
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?