[英]Search and Split the found Text
我試圖從輸入文本中找到一個位置,並將 = 后面的數字設置為變量。 不幸的是,有什么問題 output
使用我的代碼,maxresults 變量返回“i”作為結果。 但應該是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
Output:最大結果:我
但它應該是:最大結果:20
你可以用正則regexp
完成整個工作 -
if {[regexp -nocase {max=(\d+)} $text - maxresults]} {
putnow "PRIVMSG $channel :maxresults: $maxresults"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.