Re: smart split ?
- From: Glenn Jackman <glennj@xxxxxx>
- Date: 1 Jun 2007 20:49:56 GMT
At 2007-06-01 03:46PM, "sasi" wrote:
Hi,
i am looking for some solution to split a string.
my string looks like this
"Name, last", "Name, first", 123, "12/05/2007", " comments,test this",
someotherstring
i need to split it like
{Name, last} {Name, first} { 123} {12/05/2007} {comments,test
this} {someotherstring}
the problem is, i want to split it with comma (,)
but should ignore the comma with quotes
tcllib to the rescue:
% set line {"Name, last", "Name, first", 123, "12/05/2007", " comments,test this", someotherstring}
"Name, last", "Name, first", 123, "12/05/2007", " comments,test this", someotherstring
% package req csv
0.6
% set lst [csv::split $line]
{Name, last} { Name, first} { 123} { 12/05/2007} { comments,test this} { someotherstring}
I notice most of the output fields have leading spaces, so you could
string trim the results if required.
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
.
- References:
- smart split ?
- From: sasi
- smart split ?
- Prev by Date: Re: smart split ?
- Next by Date: Re: Give "curved corners" to entry widget
- Previous by thread: Re: smart split ?
- Next by thread: Secure interpreter...haven't we had that?
- Index(es):
Relevant Pages
|