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.
Help for those learning Tcl or writing their own scripts.
br00
Voice
Posts: 9 Joined: Mon Jun 19, 2006 8:09 am
Post
by br00 » Mon Jun 19, 2006 8:14 am
what it is, i have a string that always contains the word 'Size', i want to use only that which comes befor that word and forget the rest... have done some searching but to no avail
ie:
blah blah blah etc. Size
i want to use just the 'blah blah blah etc' bit (which is different every time)
so... how to cut the string at 'Size'??
deadite66
Halfop
Posts: 74 Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK
Post
by deadite66 » Mon Jun 19, 2006 10:02 am
this works for me, might be a better way though.
Code: Select all
set sline "blah blah blah etc. Size"
set oline [string range $sline 0 [expr [string first "Size" $sline] - 1]]
puts $oline
<- tcl newb
SaPrOuZy
Halfop
Posts: 75 Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon
Post
by SaPrOuZy » Mon Jun 19, 2006 4:10 pm
u could use regexp:
Code: Select all
regsub -all -- $sline "Size.*" sline ""
but be away that in both my solution and deadite66's , if the bla bla contains the word Size it will be removed too.
De Kus
Revered One
Posts: 1361 Joined: Sun Dec 15, 2002 11:41 am
Location: Germany
Post
by De Kus » Tue Jun 20, 2006 3:48 am
advise: there is also a 'string last'
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under
The MIT License
Love hurts, love strengthens...