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.

special characters in string

Old posts that have not been replied to for several years.
Locked
User avatar
droolin
Halfop
Posts: 64
Joined: Thu Jul 24, 2003 9:07 pm
Contact:

special characters in string

Post by droolin »

I have a string, where I want to strip out an ip. Example of string:

Code: Select all

chefboyrd *** Notice -- Client exiting at 3dspawn.AwesomeChat.Net: ]killa_bnuts[!~B@24.226.26.107 (Killed (DaBigun (Automated file list scripts/bots are prohibited.)))
I have no problem stripping out the ip when there are no special charactters [ ] right before the ip, but when those are in there. It's gagging and spewing. Looking on the net, I found this snippet which was said to be the proper way to do this:

Code: Select all

set arg [join [lrange [split $arg] 0 0]]
which I would think would be

Code: Select all

set arg [join [lrange [split $arg] 8 8]]
in my case, then split the ip at the @ as im doing now. Is what I think correct???? Im having problems trying to test this in tclsh. Doesnt want to allow me to set the full string with what Im trying to work with.
Any help, as always is most appriceated.


droolin
n
netux
Voice
Posts: 19
Joined: Fri Jul 30, 2004 8:42 pm

Post by netux »

if you just want the ip presuming $arg are:

Code: Select all

chefboyrd *** Notice -- Client exiting at 3dspawn.AwesomeChat.Net: ]killa_bnuts[!~B@24.226.26.107 (Killed (DaBigun (Automated file list scripts/bots are prohibited.)))
use:

Code: Select all

set ip [lindex [split [lindex [split $arg @] 1]] 0]
result in:
24.226.26.107
if you want to set host use:

Code: Select all

set host "*!*@[lindex [split [lindex [split $arg @] 1]] 0]"
result:
*!*@24.226.26.107
as i didnt have nothing to do i test it ;] and works
hope it helps
User avatar
droolin
Halfop
Posts: 64
Joined: Thu Jul 24, 2003 9:07 pm
Contact:

thank you

Post by droolin »

very much appriceated

drool
Locked