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 

how to remove part of the text from connection notices?

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


Joined: 26 Sep 2004
Posts: 10

PostPosted: Sun May 14, 2006 5:13 pm    Post subject: how to remove part of the text from connection notices? Reply with quote

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.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 14, 2006 5:54 pm    Post subject: Reply with quote

Code:
regsub {\[.*\]$} $string {} string

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Mouse
Voice


Joined: 26 Sep 2004
Posts: 10

PostPosted: Tue May 16, 2006 1:38 am    Post subject: Reply with quote

Thank you very much Very Happy

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 Very Happy
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue May 16, 2006 12:28 pm    Post subject: Reply with quote

Code:
set string [string map {\[ "" \] "" @ ""} $string]
regsub {\.[0-9]{1,}$} $string {} string

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Tue May 16, 2006 3:54 pm    Post subject: Reply with quote

and demond is calling me a regex fanatic, even if I would use simple something like:
Code:
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...
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