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

	<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>2006-04-22T02:55:42-04:00</updated>

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

		<entry>
		<author><name><![CDATA[blotter45]]></name></author>
		<updated>2006-04-22T02:55:42-04:00</updated>

		<published>2006-04-22T02:55:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=62212#p62212</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=62212#p62212"/>
		<title type="html"><![CDATA[selective whitespace trimming]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=62212#p62212"><![CDATA[
<blockquote class="uncited"><div>why not simply adding the whitespace to the re, if you really love these slow things?<div class="codebox"><p>Code: </p><pre><code>{ years?}</code></pre></div></div></blockquote>Actually I took your advice and applied it to string map instead of regsub, much better <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><div class="codebox"><p>Code: </p><pre><code>proc sr:shortdur { t } {  set t [duration $t]  set t [string map {" years" "y" " year" "y"} $t]  set t [string map {" weeks" "w" " week" "w"} $t]  set t [string map {" days" "d" " day" "d"} $t]  set t [string map {" hours" "h" " hour" "h"} $t]  set t [string map {" minutes" "m" " minute" "m"} $t]  set t [string map {" seconds" "s" " second" "s"} $t]  return $t}</code></pre></div>Thanks for the help guys!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6025">blotter45</a> — Sat Apr 22, 2006 2:55 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[De Kus]]></name></author>
		<updated>2006-04-22T02:31:21-04:00</updated>

		<published>2006-04-22T02:31:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=62209#p62209</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=62209#p62209"/>
		<title type="html"><![CDATA[selective whitespace trimming]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=62209#p62209"><![CDATA[
why not simply adding the whitespace to the re, if you really love these slow things?<div class="codebox"><p>Code: </p><pre><code>{ years?}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2382">De Kus</a> — Sat Apr 22, 2006 2:31 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[demond]]></name></author>
		<updated>2006-04-22T01:50:01-04:00</updated>

		<published>2006-04-22T01:50:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=62205#p62205</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=62205#p62205"/>
		<title type="html"><![CDATA[selective whitespace trimming]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=62205#p62205"><![CDATA[
use this:<div class="codebox"><p>Code: </p><pre><code>proc duration {t} {set days [expr $t / (3600 * 24)]set hour [expr ($t - (3600 * 24 * $days)) / 3600]set mins [expr (($t - (3600 * 24 * $days)) % 3600) / 60]if $days {append str "$days day(s), "}if $hour {append str "$hour hour(s), "}return [append str "$mins minute(s)"]}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5056">demond</a> — Sat Apr 22, 2006 1:50 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[blotter45]]></name></author>
		<updated>2006-04-22T00:50:36-04:00</updated>

		<published>2006-04-22T00:50:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=62203#p62203</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=62203#p62203"/>
		<title type="html"><![CDATA[selective whitespace trimming]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=62203#p62203"><![CDATA[
heya guys, I'm just looking for a quick way to trim out certain whitespaces from a string. Here is a proc that just takes a seconds input, takes the [duration seconds] value, and trims it down (so weeks becomes w, days becomes d, and so on):<br><div class="codebox"><p>Code: </p><pre><code>proc sr:shortdur { t } {  set t [duration $t]  regsub -all -- {years?} $t {y} t  regsub -all -- {weeks?} $t {w} t  regsub -all -- {days?} $t {d} t  regsub -all -- {hours?} $t {h} t  regsub -all -- {minutes?} $t {m} t  regsub -all -- {seconds?} $t {s} t  return $t}</code></pre></div>so a duration of "2 weeks 3 days 14 minutes 36 seconds" then becomes "2 w 3 d 14 m 36 s", but then I'd like to trim the spaces between the number and w,d,m,s so that it becomes: "2w 3d 14m 36s".. So is regsub also the best way to do that, or can you recommend another method?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6025">blotter45</a> — Sat Apr 22, 2006 12:50 am</p><hr />
]]></content>
	</entry>
	</feed>
