Regexp doesn`t work

Help for those learning Tcl or writing their own scripts.
Post Reply
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Regexp doesn`t work

Post by FcLan »

If i use one regexp with "set all" it works, but if I try to use more than 1 it doesn`t work, why?

Code: Select all

package require http

bind pub - !news www:news

proc www:news {nick host handle chan text} {
   set token [::http::geturl http://www.sensiblesoccer.de/index.php?lng=en -timeout 10000]
   set status [::http::status $token]
   if {$status!="ok"} {
      switch -exact -- [string tolower $status] {
         reset   { puthelp "PRIVMSG $chan :error: server connection was reset." }
         timeout { puthelp "PRIVMSG $chan :error: server timeout (10 seconds)"   }
         default { puthelp "PRIVMSG $chan :unknown server error occured"      }
      }
      ::http::cleanup $token; return
   }
   if {[::http::ncode $token]=="404"} {
      ::http::cleanup $token
      puthelp "PRIVMSG $chan :Sorry, error 404"; return
   }
   set data [::http::data $token]; ::http::cleanup $token
   set all [regexp -all -inline -nocase -- {<td class="medium"><b class="marker">(.*?)</font></td>} $data]
   set count 1
   foreach {tmp t} $all {
      if {$count=="4"} {return}
       incr count
   }
set all2 [regexp -all -inline -nocase -- {<td class="medium"><b class="marker">(.*?)</} $data]
set count 1
   foreach {tmp t2} $all {
      if {$count=="4"} {return}
puthelp "PRIVMSG $chan :($count) $t $t2"
}
}
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

what does not work there? All is all, there is no more. If you make another regexp on the same string it will beginng from start again and they might even return the same depending on the source.
Maybe you should write more about what you expect of the 1st and 2nd regexp.
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...
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

There are html codes for examples, but If I use it doesnt work, only works with 1 regexp.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

I suppressed the comment last time, but "Doesn't work" is no error description and therefore it won't help us to help you.
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...
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

Doesn`t work = Bot do not sends any msg to channel.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Code: Select all

.set errorInfo
Paste output.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Post Reply