Code: Select all
set ident [lindex [split $uhost @] 0]
Or with regexp:Papillon wrote:Code: Select all
set ident [lindex [split $uhost @] 0]
Code: Select all
regexp {^([^@]+)} $uhost _ ident
I just saw this for the fun.Papillon wrote:hehe
TsT, the regexp lover
I'm sorry to dissapoint you but regexp is slow, if you care about every millisecond then you should avoid regexp whenever possible
Code: Select all
bind dcc - test testproc
proc testproc {hand idx arg} {
putlog [time proc1]
putlog [time proc2]
}
proc proc1 {} {
set host "papillon!papillon@is.a.rabid.chickenkiller.com"
set data [regexp {^([^!]+)!([^@]+)@(.*)[.]{0,1}([^.]+).([^.]+)$} $host _ nick user subdom dom tld]
}
proc proc2 {} {
set host "papillon!papillon@is.a.rabid.chickenkiller.com"
set nick [lindex [split $host !] 0]
set user [lindex [split [lindex [split $host @] 0] !] 1]
set subdom [join [lrange [split [lindex [split $host @] 1] .] 0 end-1] .]
set dom [lindex [split $host .] end]
}