|
|
 |
 |
 |
 |
TCL(Tool Command Language) Scripting
|
 |
 |
 |
 |
 |
 |
 |
 |
smart split ?
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 thanks in advance, Sasi
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
In article <1180727180.133754.57@m36g2000hse.googlegroups.com>, sasi <sasidub @gmail.com> 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
. . . Does <URL: http://wiki.tcl.tk/csv > meet your needs?
prefect!!! this is what i am looking for... thank you very much. Sasi
|
 |
 |
 |
 |
|