<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/2916" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2002-11-18T12:39:01-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/2916</id>

		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2002-11-18T12:39:01-04:00</updated>

		<published>2002-11-18T12:39:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13316#p13316</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13316#p13316"/>
		<title type="html"><![CDATA[string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13316#p13316"><![CDATA[
Using a foreach word [split $arg] to chk each word for a channel, makes the eggdrop be a little slow when it's an spam. Isn't there any other alternative, maybe a faster one to do such a chk?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Nov 18, 2002 12:39 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2002-11-12T17:37:15-04:00</updated>

		<published>2002-11-12T17:37:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13096#p13096</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13096#p13096"/>
		<title type="html"><![CDATA[string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13096#p13096"><![CDATA[
<blockquote class="uncited"><div>And finaly, wich is the good code? :]</div></blockquote>It is indeed true that the conclusion was extremenly vague and poorly written:<br><blockquote class="uncited"><div>Based on the above results both the SPDY and the SPLT are good solutions</div></blockquote>Why don't you give the splt proc a try:<br><div class="codebox"><p>Code: </p><pre><code>#---------------------------------------------------------------------# split lines and test by strikelight (slightly modified) #---------------------------------------------------------------------proc stringisbad { channel string } {    if {[string first {#} $string] == -1 } { return 0 }    foreach word [split $string] {       if {![string match "*#*" $word]} { continue }       if  {[string compare -nocase $word $channel] == 0 } { continue }      return 1    }    return 0 } </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Tue Nov 12, 2002 5:37 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2002-11-12T13:54:56-04:00</updated>

		<published>2002-11-12T13:54:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13091#p13091</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13091#p13091"/>
		<title type="html"><![CDATA[string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13091#p13091"><![CDATA[
And finaly, wich is the good code? :]<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Tue Nov 12, 2002 1:54 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2002-11-01T19:14:21-04:00</updated>

		<published>2002-11-01T19:14:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12699#p12699</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12699#p12699"/>
		<title type="html"><![CDATA[string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12699#p12699"><![CDATA[
After some further messing and testing around, 3 candidates remained:<br><br>BARE: a single bare line regexp, not (yet) generical for any channel <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> (stdragon)<br>SPDY: a speedy string comparison proc (egghead/stdragon)<br>SPLT: a good old line splitting and word by word checking (strikelight, minor mod by egghead)<br><br>First some differences are highlighted in what each proc considers GOOD/BAD:<br><div class="codebox"><p>Code: </p><pre><code>Testing: BAREBARE   GOOD     join eggheadBARE   GOOD     join #eggheadBARE   GOOD     join #egghead!BARE   GOOD     join#eggheadBARE   GOOD     join #egghead for funBARE   GOOD     #eggheadBARE   GOOD     #egghead!!!aaaaaaaBARE   BAD      #egghead2BARE   GOOD     #egghead-xxxxxTesting: SPDYSPDY   GOOD     join eggheadSPDY   GOOD     join #eggheadSPDY   BAD      join #egghead!SPDY   GOOD     join#eggheadSPDY   GOOD     join #egghead for funSPDY   GOOD     #eggheadSPDY   BAD      #egghead!!!aaaaaaaSPDY   BAD      #egghead2SPDY   BAD      #egghead-xxxxxTesting: SPLTSPLT   GOOD     join eggheadSPLT   GOOD     join #eggheadSPLT   BAD      join #egghead!SPLT   BAD      join#eggheadSPLT   GOOD     join #egghead for funSPLT   GOOD     #eggheadSPLT   BAD      #egghead!!!aaaaaaaSPLT   BAD      #egghead2SPLT   BAD      #egghead-xxxxx</code></pre></div>Next the procs are tested against a list of 20 identical strings, each string being "hello #egghead join #xxx for great fun"<br><div class="codebox"><p>Code: </p><pre><code>Testing 20 strings WITH channel names (10000 times)BARE:  855 microseconds per iteration (average of 42 microseconds per line)SPDY:  741 microseconds per iteration (average of 37 microseconds per line)SPLT:  807 microseconds per iteration (average of 40 microseconds per line)BARE:  919 microseconds per iteration (average of 45 microseconds per line)SPDY:  758 microseconds per iteration (average of 37 microseconds per line)SPLT:  806 microseconds per iteration (average of 40 microseconds per line)</code></pre></div>Several tests indicated that the SPDY and SPLT are the fastest, but the differences between the 3 are minor.<br><br>Next the procs were tested against 20 identical strings without any channel name in it ("hello world, this is a line"):<div class="codebox"><p>Code: </p><pre><code>Testing 20 strings WITHOUT channel names (10000 times)BARE:  364 microseconds per iteration (average of 18 microseconds per line)SPDY:  235 microseconds per iteration (average of 11 microseconds per line)SPLT:  753 microseconds per iteration (average of 37 microseconds per line)BARE:  366 microseconds per iteration (average of 18 microseconds per line)SPDY:  301 microseconds per iteration (average of 15 microseconds per line)SPLT:  750 microseconds per iteration (average of 37 microseconds per line)</code></pre></div>In this case SPLT has some difficulties to catch up, because it has to check each word in the line up to the last one for the presence of a channel name. These differences can be amplified by adding more words to the line.<br><br>Finally, the procs are tested against 20 identical lines containing 8 times the valid channelname as words in it ("#egghead #egghead etc...):<br><div class="codebox"><p>Code: </p><pre><code>Testing 20 strings WITH channel names (1000 times)BARE: 2221 microseconds per iteration (average of 111 microseconds per line)SPDY: 2283 microseconds per iteration (average of 114 microseconds per line)SPLT: 1250 microseconds per iteration (average of 62 microseconds per line)BARE: 2646 microseconds per iteration (average of 132 microseconds per line)SPDY: 2275 microseconds per iteration (average of 113 microseconds per line)SPLT: 1230 microseconds per iteration (average of 61 microseconds per line)</code></pre></div>In this extreme case the SPLT proc clearly is the fastest. These results can be further amplified by adding the channel name a couple of times more. In such case the SPLT will remain the fastest, followed by BARE and SPDY as last one.<br><br>Based on the above results both the SPDY and the SPLT are good solutions. If the proc has to be used to check general IRC conversation, then the SPDY proc is preferred over the SPLT proc. In that case the SPLT proc can be upgraded, by adding the line "if {[string first {#} $string] == -1 } { return 0 }" as the first line in the proc.<br><br>It will be very interesting to see how the results compare with a proc using an [lsearch -all -inline] (available in Tcl 8.4) followed by a channelname check.<br><br>Finally, as mentioned by stdragon, note that there are no checks for valid word separators in the SPDY and LIST proc, there is some in the BARE proc.<br>Adding such check, which is left as a trivial exercise for the interested reader, will raise the timing results of the SPDY and the LIST procs in an identical way, since they perform the channel name checks in the same way.<br><br>The procs:<br><div class="codebox"><p>Code: </p><pre><code>#--------------------------------------------------------------------- # one line regexp by stdragon#--------------------------------------------------------------------- proc stringisbadBARE { channel string } {   if { [regexp -nocase {#(?!egghead(\W|$))} $string] } { return 1 }   return 0}#--------------------------------------------------------------------- # split lines and test by strikelight (slightly modified)#--------------------------------------------------------------------- proc stringisbadSPLT { channel string } {#   if {[string first {#} $string] == -1 } { return 0 }   foreach word [split $string] {       if {![string match "*#*" $word]} { continue }      if  {[string compare -nocase $word $channel] == 0 } { continue }      return 1   }    return 0}#--------------------------------------------------------------------- # review occurances of # in string (egghead/stdragon)#--------------------------------------------------------------------- proc stringisbadSPDY {channel string } {    set idx 0    while {[set idx [string first {#} $string $idx]] != -1} {      set space [string first { } $string $idx]       if {$space == -1} {set space end} {incr space -1}       set word [string range $string $idx $space]       if {[string compare -nocase $channel $word ]} {return 1}       set idx $space    }    return 0} </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Fri Nov 01, 2002 7:14 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2002-11-01T12:44:04-04:00</updated>

		<published>2002-11-01T12:44:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12690#p12690</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12690#p12690"/>
		<title type="html"><![CDATA[string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12690#p12690"><![CDATA[
I think I can improve on that :)<br><div class="codebox"><p>Code: </p><pre><code># based on egghead's codeproc string2isbad {chan line} {  set idx 0  while {[set idx [string first {#} $line $idx]] != -1} {    set space [string first { } $line $idx]    if {$space == -1} {set space end} {incr space -1}    set word [string range $line $idx $space]    if {[string compare -nocase $chan $word ]} {return 1}    set idx $space  }  return 0}</code></pre></div>Of course, both of these don't check for valid word separators like commas, periods, exclamation points, question marks.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Fri Nov 01, 2002 12:44 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2002-11-01T09:38:01-04:00</updated>

		<published>2002-11-01T09:38:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12673#p12673</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12673#p12673"/>
		<title type="html"><![CDATA[string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12673#p12673"><![CDATA[
Call me a freak, but the following snippet is also submitted for competition <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><div class="codebox"><p>Code: </p><pre><code>proc stringisbad { channel string } {   # find first occurance of #, abort if none   # dont like while loops, but competition is fierce :)   while { [set index [string first "#" $string]] != -1 } {      # strip first part from string      set string [string range $string $index end]      # find occurance of space and set index accordingly      set indsp [string first { } $string]      # if space not found set to string end, else set to word end      if { $indsp == -1 } { set indsp end } else { incr indsp -1 }      # retrieve channel name      set channame [string range $string 0 $indsp]      # compare channel names      if { ![string equal -nocase $channame $channel] } { return 1 }       # update the string      set string [string range $string $indsp end]   }   # iterated on all words, but nothing bad found :)   return 0}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Fri Nov 01, 2002 9:38 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2002-11-01T05:35:51-04:00</updated>

		<published>2002-11-01T05:35:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12661#p12661</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12661#p12661"/>
		<title type="html"><![CDATA[string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12661#p12661"><![CDATA[
<blockquote class="uncited"><div>Have you tried a single regexp?<br><br>% set line "hello #egghead everybody come to #egghead2"<br>hello #egghead everybody come to #egghead2<br>% time {regexp -nocase {#(?!egghead(\W|$))} $line} 1000<br>9 microseconds per iteration<br><br>The code seems a bit simpler <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"></div></blockquote>The single line regexp works fine with the functionality of the snippets I produced. But before comparing it to the other candidates, I need it in a form where the channel name can be set separately, including the # character. This will mimic the practical situation where a proc is called with 2 arguments: a channel name and a string.<br>Naturally, I can produce these "preprocessing" lines myself, but they are not necessarily the best ones <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br>Once I have these preprocessing lines, I'll put it in a proc form and compare it to the other procs.<br><div class="codebox"><p>Code: </p><pre><code>proc stringisbad { channel string } {   # some preprocessing to strip the # from the    # channel name and build the regexp...   # regexp test returning either 0 or 1...}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Fri Nov 01, 2002 5:35 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2002-10-31T21:09:11-04:00</updated>

		<published>2002-10-31T21:09:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12656#p12656</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12656#p12656"/>
		<title type="html"><![CDATA[string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12656#p12656"><![CDATA[
Have you tried a single regexp?<br><br>% set line "hello #egghead everybody come to #egghead2"<br>hello #egghead everybody come to #egghead2<br>% time {regexp -nocase {#(?!egghead(\W|$))} $line} 1000<br>9 microseconds per iteration<br><br>The code seems a bit simpler :)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Thu Oct 31, 2002 9:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2002-10-31T19:22:21-04:00</updated>

		<published>2002-10-31T19:22:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12651#p12651</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12651#p12651"/>
		<title type="html"><![CDATA[string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12651#p12651"><![CDATA[
If you intend to use snippets of this thread produced by myself, they are free to use (if of any use). A "bind pubm - {* *#*} proc" defiantly will come handy <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Thu Oct 31, 2002 7:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-10-31T18:20:40-04:00</updated>

		<published>2002-10-31T18:20:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12649#p12649</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12649#p12649"/>
		<title type="html"><![CDATA[string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12649#p12649"><![CDATA[
May I include this in no-spam?<br><br>This is somthing people have been crying out for, Bu ti have been unable to generate somthing small and fast enough to deal with large load channels - nospam is packed as it is.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Thu Oct 31, 2002 6:20 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stere0]]></name></author>
		<updated>2002-10-31T17:47:28-04:00</updated>

		<published>2002-10-31T17:47:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12648#p12648</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12648#p12648"/>
		<title type="html"><![CDATA[full]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12648#p12648"><![CDATA[
<strong class="text-strong">so, wich is the final full script?</strong> Can u paste or send to me?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4">stere0</a> — Thu Oct 31, 2002 5:47 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2002-10-31T05:29:21-04:00</updated>

		<published>2002-10-31T05:29:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12623#p12623</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12623#p12623"/>
		<title type="html"><![CDATA[Mudding]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12623#p12623"><![CDATA[
After some further mudding around, four solutions were tested:<br><br>1. REXP: solution using regexp, first script egghead<br>2. SPLT: iterate on each word in a string, first script strikelight<br>3. MODF: iterate on each word, modified version strikelight<br>4. FAST: iterate on each word using string functions only (code given below)<br><br>Running the full set of lines given previously containing channel names, produced the following results on the shell (averaged over 10000 iterations).<br><br>REXP: 1611 microseconds per iteration<br>SPLT: 740 microseconds per iteration<br>MODF: 970 microseconds per iteration<br>FAST: 639 microseconds per iteration<br><br>Clearly the REXP solution is the most expensive  one, about twice the other 3 solutions. Another observation is that the modified script does not perform better compared to the script that splits the string in words and checks on each word.<br><br>Next a set of 20 strings NOT containing a #channel name , each line having 6 words ("hello world, this is a line") was tested.<br><br>The timing results:<br>REXP: 150 microseconds per iteration<br>SPLT: 991 microseconds per iteration<br>MODF: 781 microseconds per iteration<br>FAST: 164 microseconds per iteration<br><br>In this case the REXP is dead cheap as it directly detects that there are  no "#" characters in the line.<br><br>To mimic behaviour with a "bind PUBM - {* *#*} " by putting the line "if {[string first "#" $string] == -1 } { return 0 }" right at the start of the SPLT and MODF scripts (i.e. first checking for the presence of a # character in the string), the following results are obtained. <br><br>REXP: 150 microseconds per iteration<br>SPLT: 153 microseconds per iteration<br>MODF: 157 microseconds per iteration<br>FAST: 156 microseconds per iteration<br><br>As stated somewhere else in this thread, the option of using a <ul> <li>has not been tested.<br><br>All in all, the idea of splitting the line and checking each word resulted in another piece, shown below. This script produced the results under FAST. Note that this script will consider "join#egghead" as good and "join#xxx" as bad.<br><div class="codebox"><p>Code: </p><pre><code>proc stringisbad { string } {   # omit sentences without # in it   if {[set index [string first "#" $string]] == -1 } { return 0 }   # remove first part of the string   set string [string range $string $index end]   # allowed channel   set channel #egghead   # split the line into a list of words   set list [split $string]   # iterate on the words   foreach word $list {      # if word does not contain a "#" then continue ...      if { [set index [string first "#" $word]] == -1 } { continue }      # ... else retrieve channel name      set channame [string range $word $index end]      # if found name is not allowed name then string is bad      if { $channame != $channel } { return 1 }   }   # iterated on all words, but nothing bad found :)   return 0}</code></pre></div></li></ul><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Thu Oct 31, 2002 5:29 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[strikelight]]></name></author>
		<updated>2002-10-30T21:28:36-04:00</updated>

		<published>2002-10-30T21:28:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12618#p12618</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12618#p12618"/>
		<title type="html"><![CDATA[Re: string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12618#p12618"><![CDATA[
<blockquote class="uncited"><div><br>Actually, Tcl8.4 has an [lsearch -all -inline] option which in principle should be able to produce immediately a list of matches. Unfortunately <br>I'm still on Tcl8.3, so I couldn't test that idea <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"></div></blockquote>Same here...  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_confused.gif" width="15" height="15" alt=":-?" title="Confused"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2005">strikelight</a> — Wed Oct 30, 2002 9:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[strikelight]]></name></author>
		<updated>2002-10-30T21:27:12-04:00</updated>

		<published>2002-10-30T21:27:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12617#p12617</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12617#p12617"/>
		<title type="html"><![CDATA[Re: string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12617#p12617"><![CDATA[
<blockquote class="uncited"><div><br><br>Another drawback of doing a word by word check, is that it's not cheap on the average say 5 to 10 word sentences not containing any "#" char. Maybe doing a check for the presence of a # char in the string before going to a word by word check can solve this.</div></blockquote>Already addressed this in my modification on my post containing the example, with the lsort, lrange, etc...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2005">strikelight</a> — Wed Oct 30, 2002 9:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2002-10-30T21:26:35-04:00</updated>

		<published>2002-10-30T21:26:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12616#p12616</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12616#p12616"/>
		<title type="html"><![CDATA[Re: string match]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12616#p12616"><![CDATA[
<blockquote class="uncited"><div><br>or to cut down on iterations while still actually verifying each channel name..<br><div class="codebox"><p>Code: </p><pre><code>set bad 0set mylist [lsort [split [string tolower $arg]]]set aloc [lsearch $mylist #*]if {$aloc == -1} { return }set mylist [lrange $mylist $aloc end]foreach word $mylist {  if {![string match "#*" $word]} { break }  if {$word != [string tolower $chan]} { set bad 1 }}if {!$bad} { return }</code></pre></div></div></blockquote>Actually, Tcl8.4 has an [lsearch -all -inline] option which in principle should be able to produce immediately a list of matches. Unfortunately I'm still on Tcl8.3, so I couldn't test that idea <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Wed Oct 30, 2002 9:26 pm</p><hr />
]]></content>
	</entry>
	</feed>
