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 

removing end of a string

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


Joined: 05 Mar 2009
Posts: 60

PostPosted: Fri Nov 27, 2009 2:52 am    Post subject: removing end of a string Reply with quote

Hi - I'm trying to get rid of the date/month/year on the end of these news headlines:

UK's Brown hopes Zimbabwe can rejoin Commonwealth 27 Nov 2009

At the moment I'm doing it by setting the 27 Nov 2009 part as a variable from another part of the webpage, and doing a string trimright to remove the variable. The problem then is, whenever a 27 or Nov or 2009 appears in the actual headline itself, it's trimming everything else with it:

eg.
African Markets - Factors to watch on Nov 27 27 Nov 2009
appears as just:
African Markets - Factors to watch on

any help to just lose the right-hand side date would be much appreciated!
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Nov 27, 2009 3:48 am    Post subject: Reply with quote

I suppose ome way around would be to use the string range command. You'd have to get the length of the strings first though (string length) and do some maths...

Not sure if string trimright would do the trick either?
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
NewzNZ
Halfop


Joined: 05 Mar 2009
Posts: 60

PostPosted: Sat Nov 28, 2009 9:53 pm    Post subject: Reply with quote

thanks for those ideas nml375...

I actually got it working using regexp by putting the data variable at the end...should have thought of it earlier!

thanks again =)
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Nov 28, 2009 10:27 pm    Post subject: Reply with quote

Quote:
eg.
African Markets - Factors to watch on Nov 27 27 Nov 2009
appears as just:
African Markets - Factors to watch on

If it's always 3 space separated elements at the end you want omitted. You can use join, lrange and split to do it as well, assuming $text is our string.

set text [join [lrange [split $text] 0 end-3]]
Quote:
<speechles> .tcl set text "African Markets - Factors to watch on Nov 27 27 Nov 2009"
<bot> Tcl: African Markets - Factors to watch on Nov 27 27 Nov 2009
<speechles> .tcl set text [join [lrange [split $text] 0 end-3]]
<bot> Tcl: African Markets - Factors to watch on Nov 27

_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
NewzNZ
Halfop


Joined: 05 Mar 2009
Posts: 60

PostPosted: Sat Nov 28, 2009 10:49 pm    Post subject: Reply with quote

ah yep thanks speechles...that's cool. it's like the '$mid' use in mIRC scripting that I was looking for.

thanks also!
Back to top
View user's profile Send private message Visit poster's website
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