This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
Craig
Voice
Posts: 18 Joined: Wed Feb 22, 2006 2:18 pm
Post
by Craig » Thu Mar 22, 2007 4:00 pm
Code: Select all
; set arg "lol http:// http://lol www.lol www ftp:// lol ftp://:P"
#101 (56 clicks) Tcl: lol http:// http://lol www.lol www ftp:// lol ftp://:P
; set arg [lsearch -regexp -all -inline $arg {(http://|www.|ftp://)}]
#103 (121 clicks) Tcl: http:// http://lol www.lol ftp:// ftp://:P
i dont understand you, lsearch is working with $arg and also when i'll try "putquick : privmsg $chan $bwfound" it will return that words. :O
Code: Select all
set bwfound [lsearch -regexp -all -inline $arg {(http://|www.|ftp://)}]
putquick " privmsg $chan : BW FOUNDED: $bwfound"
>>
10.:142110·140010·140810:. 03«~Thiev03» http:// lol ftp:// lol
http://lol lol
ftp://lol lol
10.:142110·140010·140810:. 03«@dghnws03» cos znalazlem!
10.:142110·140010·140810:. 03«@dghnws03» BW FOUNDED: http:// ftp://
http://lol ftp://lol
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Thu Mar 22, 2007 4:03 pm
The problem is that arg can never contain a newline, yet you use a mask that does contain a newline... should be quite obvious the mask will never match..
And as for lsearch:ing arg, you're just getting away with with sheer luck.. should arg contain characters such as {[]} and similar, you'd be up for a "nice" surprise...
NML_375
Craig
Voice
Posts: 18 Joined: Wed Feb 22, 2006 2:18 pm
Post
by Craig » Fri Mar 23, 2007 12:03 pm
tell me how to do thing like
if { ([string match -nocase "* $helpwanted *" $input] ===== 1
i want to it replay 0 when there is full zeros like
in $helpwanted is
bla
he
hi
andf return 0 if no one word match with $input ..
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Fri Mar 23, 2007 1:52 pm
Use proper lists and do a foreach loop to use each list item as a pattern with "string match", don't expect "string match" to pick a part of the pattern and match it against the text-string.
That is, given that "patterns" holds a valid list structure and "text" the text string, something like this:
Code: Select all
foreach item $patterns {
if {[string match $item $text]} {
puts stdout "It matched!!!"
break
}
}
NML_375