cmd: .s FIRST LAST
Code: Select all
FIR
text1
text2
text3
FIRST
text4
text5
text6
LAST
text7
text8
text9
NEXT
[...]
text4
text5
text6
all between FIRST and LAST.
Thx for help
Code: Select all
FIR
text1
text2
text3
FIRST
text4
text5
text6
LAST
text7
text8
text9
NEXT
[...]
Code: Select all
proc s { w f l } {
set fp [open $w r] ; set d [split [read $fp] \n] ; close $fp
set r [lrange $d [expr {[lsearch $d $f]+1}] [expr {[lsearch $d $l]-1}]]
}
obviously you'd also check to see if file exists/readable (if you're reading from a file), and you should check if the lsearch fails% s <file> FIRST LAST
text4 text5 text6
Code: Select all
FIR
random text1
random text2
random text3
FIRST
random text4
random text5
random text6
LAST
random text7
random text8
random text9
NEXT
[...]
Code: Select all
set somestring "FIR\nrandom1\nrandom2\nrandom3\nFIRST\nrandom4\nrandom5\nrandom6\nLAST\nrandom7\netc"
bind pub n .s pub:s
proc pub:s { n u h c t } {
if {[llength [split $t]] != 2} { puthelp "PRIVMSG $c :usage: .s <first> <last>" ; return }
if {[set result [s [lindex [split $t] 0] [lindex [split $t] 1]]] != "ERROR" } {
foreach l $result { puthelp "PRIVMSG $c :$l" }
return
}
puthelp "PRIVMSG $c :$result"
return
}
proc s { f l } {
set d [split $::somestring \n] ;# set d $::somestring (if it's a list)
if {[set f [lsearch $d $f]] != -1 && [set l [lsearch $d $l]] != -1} {
set r [lrange $d [expr {$f+1}] [expr {$l-1}]]
} { return ERROR }
}
<you> .s FIRST LAST
<bot> random4
<bot> random5
<bot> random6
can also use wildcards
<you> .s *IRS* *AST
<bot> random4
<bot> random5
<bot> random6