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.
Mouse
Voice
Posts: 10 Joined: Sun Sep 26, 2004 8:07 pm
Post
by Mouse » Sun May 14, 2006 5:13 pm
Im working on re-linking script for unrealircd
in order for eggdrop to auto relink the server.
have to remove this part from connection notice.
hub.000.com[24.24.24.24]
have to remove [24.24.24.24] so
eggdrop can do /connect hub.000.com
I been reading about regsub, but Im not sure about what to use to strip the part.
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sun May 14, 2006 5:54 pm
Code: Select all
regsub {\[.*\]$} $string {} string
Mouse
Voice
Posts: 10 Joined: Sun Sep 26, 2004 8:07 pm
Post
by Mouse » Tue May 16, 2006 1:38 am
Thank you very much
I need help with this thing
I need to strip @, [, ], last . and 4 numbers?
how to strip last numbers and last . ?
[@63.24.93.77.1110]
should be 63.24.93.77
Thank you
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Tue May 16, 2006 12:28 pm
Code: Select all
set string [string map {\[ "" \] "" @ ""} $string]
regsub {\.[0-9]{1,}$} $string {} string
De Kus
Revered One
Posts: 1361 Joined: Sun Dec 15, 2002 11:41 am
Location: Germany
Post
by De Kus » Tue May 16, 2006 3:54 pm
and demond is calling me a regex fanatic, even if I would use simple something like:
Code: Select all
set id [string last . [set string [string trim $string {[]@}]]]
set string [string range $string 0 [expr {$id -1}]]
instead of string trim, you can use another string range, but to keep flexibility of the port number it might be better that way, you can then also get the port with [string range $string [expr {$id +1}] end] (if you save the other one somewhere else), in case it is even neccessary ^-^.
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...