Search and Split the found Text


I’m trying to find a place from the input text and set the number after the = as a variable. Unfortunately, what is wrong output

With my code, the maxresults variable returns "i" as the result. But it should be 20.


bind pub "-|-" !a pub:a
proc pub:a { nick host handle channel text } {

    set maxresults ""
    if {[regexp -nocase {max=} $text]} {
    set maxresults0 [lindex [split $text max=] 1]
    set maxresults [lindex $maxresults0 0]
    putnow "PRIVMSG $channel :maxresults: $maxresults"

!a Remix find now country=german max=20 currency=euro

maxresults: i

but it should be:
maxresults: 20

>Solution :

You can do the whole job with regexp

if {[regexp -nocase {max=(\d+)} $text - maxresults]} {
    putnow "PRIVMSG $channel :maxresults: $maxresults"

See the documentation at

Leave a Reply Cancel reply