This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

List Help

Old posts that have not been replied to for several years.
Locked
E
Esoteric
Voice
Posts: 19
Joined: Mon Apr 11, 2005 1:08 pm

List Help

Post by Esoteric »

I have a string of text that I need to split into a list so that I can assign the information accordingly. Below I have a sample of the text. This is what I need done.

First split the string on the : (colon) then search the first column of te split for a keyword, if it has the word in it then append it to another list. and so on. I figured the easiest way would to put the each section separated by the : into an element of an array or something, but I just don't know tcl that well. Can anyone help?


info,(info2):info,(info2):info,(info2):info,(info2):info,(info2):info,(info2)
-Erik
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

set string "info,(info2):info,(info2):info,(info2):info,(info2):info,(info2):info,(info2)"

foreach info [split $string :] {
 if {[string match -nocase *keyword* $info]} {
  #matched
 }
}
this will search for keyword in every info between ':'
E
Esoteric
Voice
Posts: 19
Joined: Mon Apr 11, 2005 1:08 pm

Post by Esoteric »

Sweet! Just what I was looking for! Thanks
-Erik
Locked