| View previous topic :: View next topic |
| Author |
Message |
NewzNZ Halfop

Joined: 05 Mar 2009 Posts: 60
|
Posted: Fri Nov 27, 2009 2:52 am Post subject: removing end of a string |
|
|
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Nov 27, 2009 3:48 am Post subject: |
|
|
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 |
|
 |
NewzNZ Halfop

Joined: 05 Mar 2009 Posts: 60
|
Posted: Sat Nov 28, 2009 9:53 pm Post subject: |
|
|
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 |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Nov 28, 2009 10:27 pm Post subject: |
|
|
| 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 |
|
 |
NewzNZ Halfop

Joined: 05 Mar 2009 Posts: 60
|
Posted: Sat Nov 28, 2009 10:49 pm Post subject: |
|
|
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 |
|
 |
|