<?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/13022" />

	<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>2007-01-26T15:19:49-04:00</updated>

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

		<entry>
		<author><name><![CDATA[rlgraham]]></name></author>
		<updated>2007-01-26T15:19:49-04:00</updated>

		<published>2007-01-26T15:19:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69960#p69960</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69960#p69960"/>
		<title type="html"><![CDATA[lsearch regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69960#p69960"><![CDATA[
Then I guess I will go with your suggestion of stepping through the segments to find all my HDR's. <br><br>Thanks so much for your time, I really appreciate it.<br><br>Ricci<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8647">rlgraham</a> — Fri Jan 26, 2007 3:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2007-01-26T15:16:38-04:00</updated>

		<published>2007-01-26T15:16:38-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69959#p69959</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69959#p69959"/>
		<title type="html"><![CDATA[lsearch regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69959#p69959"><![CDATA[
* is a wildcard used with glob-style matching, not regular expressions. It will match 0 or more characters (including whitespaces and other "special" characters).<br><br>Using *-wildcard with glob-style matching in lsearch would mean it would match each list-item against *, which would match the first item in the list, and hence return the list index for that item (obviously 0).<br><br>There is no *-argument.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Jan 26, 2007 3:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rlgraham]]></name></author>
		<updated>2007-01-26T15:12:00-04:00</updated>

		<published>2007-01-26T15:12:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69957#p69957</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69957#p69957"/>
		<title type="html"><![CDATA[lsearch regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69957#p69957"><![CDATA[
I thought in the older version you could use a * instead of the -all and get the same thing, but it gives me the same error. I thought I just had the syntax wrong. Are you familar with the * matching all?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8647">rlgraham</a> — Fri Jan 26, 2007 3:12 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2007-01-26T15:08:35-04:00</updated>

		<published>2007-01-26T15:08:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69956#p69956</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69956#p69956"/>
		<title type="html"><![CDATA[lsearch regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69956#p69956"><![CDATA[
Unfortunately, 8.0 lacks many features such as the -all argument with <a href="http://www.tcl.tk/man/tcl8.0/TclCmd/lsearch.htm" class="postlink">lsearch</a>.<br><br>I would guess the simplest approach (next to bugging your admin to upgrade tcl to 8.4ish), would be to manually step through the list (foreach) and manually test each list-item with <a href="http://www.tcl.tk/man/tcl8.0/TclCmd/regexp.htm" class="postlink">regexp</a>, possibly building a new list based on wether each item pass or fail the regexp-test...<br><br>ie:<div class="codebox"><p>Code: </p><pre><code>set new_segments {}set HDRKeep 0foreach item $segments { if {[regexp -- {^HDR} $item]} {  if {$HDRKeep == 0} {   lappend new_segments $item   set HDRKeep 1  } } else {  lappend new_segments $item }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Jan 26, 2007 3:08 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rlgraham]]></name></author>
		<updated>2007-01-26T14:57:21-04:00</updated>

		<published>2007-01-26T14:57:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69955#p69955</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69955#p69955"/>
		<title type="html"><![CDATA[lsearch regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69955#p69955"><![CDATA[
version 8.0<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8647">rlgraham</a> — Fri Jan 26, 2007 2:57 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2007-01-26T14:55:04-04:00</updated>

		<published>2007-01-26T14:55:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69954#p69954</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69954#p69954"/>
		<title type="html"><![CDATA[lsearch regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69954#p69954"><![CDATA[
Could you check which version of tcl you are using? Some features are not available in all versions in use today.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Jan 26, 2007 2:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rlgraham]]></name></author>
		<updated>2007-01-26T14:53:09-04:00</updated>

		<published>2007-01-26T14:53:09-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69953#p69953</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69953#p69953"/>
		<title type="html"><![CDATA[lsearch regexpr]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69953#p69953"><![CDATA[
I had tried that and it gives this error:<br><br>wrong # args: should be "lsearch ?mode? list pattern"<br>  while executing<br>"lsearch -regexp -all $segments {^HDR}"<br><br>so that is why I was trying to get another idea of the way to use the syntax. Any other ideas?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8647">rlgraham</a> — Fri Jan 26, 2007 2:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2007-01-26T14:46:42-04:00</updated>

		<published>2007-01-26T14:46:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69952#p69952</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69952#p69952"/>
		<title type="html"><![CDATA[lsearch regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69952#p69952"><![CDATA[
something like this I suppose:<div class="codebox"><p>Code: </p><pre><code>set HDRLocList [lsearch -regexp -all $segments {^HDR}]set HDRKeep 0foreach HDRLoc $HDRLocList { set HDR [lindex $segments $HDRLoc] ...}</code></pre></div>In case you're thinking of using lreplace to remove any (and all) HDR segments, be advised that the first lreplace operation would most likely make the list from lsearch invalid, unless you use a "lazy-delete" style of removal...<br><br>IE. <div class="codebox"><p>Code: </p><pre><code>set segments [lreplace $segments $HDRLoc $HDRLoc]</code></pre></div> would make the list of HDR-locations invalid, as it alters the list structure; one possible option might be <div class="codebox"><p>Code: </p><pre><code>set segments [lreplace $segments $HDRLoc $HDRLoc {}]</code></pre></div> which does not remove the actual list-entity, but just clears it, and thus retains the integrity of the list of HDR-locations<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Jan 26, 2007 2:46 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rlgraham]]></name></author>
		<updated>2007-01-26T14:35:20-04:00</updated>

		<published>2007-01-26T14:35:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69950#p69950</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69950#p69950"/>
		<title type="html"><![CDATA[lsearch regexpr]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69950#p69950"><![CDATA[
That is what I thought I should use, can you show me the syntax for the line I have in bold?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8647">rlgraham</a> — Fri Jan 26, 2007 2:35 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2007-01-26T14:31:37-04:00</updated>

		<published>2007-01-26T14:31:37-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69949#p69949</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69949#p69949"/>
		<title type="html"><![CDATA[lsearch regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69949#p69949"><![CDATA[
Tried the -all option? Should make lsearch return a list rather than a single value, which you then should be able to use with a foreach-loop...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Jan 26, 2007 2:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rlgraham]]></name></author>
		<updated>2007-01-26T12:47:51-04:00</updated>

		<published>2007-01-26T12:47:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=69948#p69948</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=69948#p69948"/>
		<title type="html"><![CDATA[lsearch regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=69948#p69948"><![CDATA[
I am writing a tcl script and I am not familar with how to use the <br><br>lsearch -regexp command to get "all" the segments in a file. Here is a peice of my code:<div class="codebox"><p>Code: </p><pre><code>if {$filenum &gt; 0} { set filename [lindex $filelist 0] set fileid [open $filename r] set newfile [read $fileid] set segments [split $newfile \r]#Here is where I need to know how to get all of the HDR segments not# just the first one?[b] set HDRLoc [lsearch -regexp $segments {^HDR}][/b]</code></pre></div>My goal is to strip out all the HDR segments except the first one.<br><br>Any suggestions will be greatly appreciated.<br><br>Thanks,<br><br>Ricci<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8647">rlgraham</a> — Fri Jan 26, 2007 12:47 pm</p><hr />
]]></content>
	</entry>
	</feed>
