[英]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
不幸的是,有什么问题 output
With my code, the maxresults variable returns "i" as the result.使用我的代码,maxresults 变量返回“i”作为结果。 But it should be 20.
但应该是20。
Code:代码:
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"
}
}
Input: !a Remix find now country=german max=20 currency=euro输入:!a Remix find now country=german max=20 currency=euro
Output: maxresults: i Output:最大结果:我
but it should be: maxresults: 20但它应该是:最大结果:20
You can do the whole job with regexp
-你可以用正则
regexp
完成整个工作 -
if {[regexp -nocase {max=(\d+)} $text - maxresults]} {
putnow "PRIVMSG $channel :maxresults: $maxresults"
}
See the documentation at http://www.tcl-lang.org/man/tcl8.6/TclCmd/regexp.htm请参阅文档http://www.tcl-lang.org/man/tcl8.6/TclCmd/regexp.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.