egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

string help (using a specific part of a string?)

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
br00
Voice


Joined: 19 Jun 2006
Posts: 9

PostPosted: Mon Jun 19, 2006 8:14 am    Post subject: string help (using a specific part of a string?) Reply with quote

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'??
Back to top
View user's profile Send private message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Mon Jun 19, 2006 10:02 am    Post subject: Reply with quote

this works for me, might be a better way though.

Code:
set sline "blah blah blah etc. Size"
set oline [string range $sline 0 [expr [string first "Size" $sline] - 1]]
puts $oline

_________________
<- tcl newb
Back to top
View user's profile Send private message
SaPrOuZy
Halfop


Joined: 24 Mar 2004
Posts: 75
Location: Lebanon

PostPosted: Mon Jun 19, 2006 4:10 pm    Post subject: Reply with quote

u could use regexp:
Code:
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.
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Tue Jun 20, 2006 3:48 am    Post subject: Reply with quote

advise: there is also a 'string last' Smile
_________________
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...
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber