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

	<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>2011-01-01T05:24:28-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Elfriede]]></name></author>
		<updated>2011-01-01T05:15:42-04:00</updated>

		<published>2011-01-01T05:15:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95529#p95529</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95529#p95529"/>
		<title type="html"><![CDATA[[solved] regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95529#p95529"><![CDATA[
Perfect ! Thank you very, very much speechles - exactly how i imagined it <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=9204">Elfriede</a> — Sat Jan 01, 2011 5:15 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2010-12-31T18:45:55-04:00</updated>

		<published>2010-12-31T18:45:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95522#p95522</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95522#p95522"/>
		<title type="html"><![CDATA[[solved] regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95522#p95522"><![CDATA[
Regex isn't the simplest solution in this case. This is easier than you are making it seem. Use the example below and add as many switches as you would like. <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>... add this inside your proc ...# init search variables, create empty listsset search [list] ; set search_a [list] ; set search s [list]# iterate user input, parse out switchesforeach word [split $text] {# parse switches with the switch statement. oh the irony ;)# [string range $word 3 end] removes the switch itself from# the word before adding the rest of the word to those lists.switch -glob -- $word {"-a=*" { lappend search_a [string range $word 3 end] }"-s=*" { lappend search_s [string range $word 3 end] }default { lappend search $word }}}# join the search, search_a, and search_s lists into strings we can useset search [join $search] ; set search_a [join $search_a] ; set search_s [join $search_s]# Use these 3 variables in your script now.# $search = users search terms# $search_a = all switches starting with -a combined# $search_s = all switches starting with -s combined</code></pre></div>Doing it this way, allows for any combinations and placements as well as stacking switches or search elements. This way is intuitive.<br><br>Any terms with known switches are applied to each switches list, which makes it possible to stack switches or search elements like the example below:<br><br>-s=foo my%search% -a=we -a=also -a=this -a=too -s=bar<br><br>in the above case, this is how the three variables you get would look:<br>$search = my%search%<br>$search_a = we also this too<br>$search_s = foo bar<br><br>This should be how you envisioned it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Fri Dec 31, 2010 6:45 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Elfriede]]></name></author>
		<updated>2010-12-31T13:55:35-04:00</updated>

		<published>2010-12-31T13:55:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95521#p95521</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95521#p95521"/>
		<title type="html"><![CDATA[[solved] regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95521#p95521"><![CDATA[
ok ill try to explain different. My bot can search in a mysql database. therefore ive coded a command !regex, which should support different switches, as easy as possible.<br><br>1. !regex search phrase - supporting wildcards like !regex %search%<br>2. the switches are like -a= and -s=<br><br>Examples: <br>!regex my%search% -a=we<br>!regex -a=we my%search%<br>!regex my%search% -a=we -s=we2<br>!regex -s=we2 -a=we my%search%<br><br>Im looking for a way to get the switches and the searchphrase fast and "easy". If possible it shouldnt matter, in which order they are used.<br><br>Hope this describes it better and someone can provide me a solution <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Happy New Year!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9204">Elfriede</a> — Fri Dec 31, 2010 1:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2010-11-09T19:42:12-04:00</updated>

		<published>2010-11-09T19:42:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95017#p95017</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95017#p95017"/>
		<title type="html"><![CDATA[[solved] regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95017#p95017"><![CDATA[
You might need to be somewhat clearer regarding your needs in order to elicit a satisfactory response.<br><br>In the meantime, if it is any help, it is possible to use a regular expression to search for a word or phrase.<br><div class="codebox"><p>Code: </p><pre><code>[23:13] &lt;@arfer&gt; % set phrase "hello there"[23:13] &lt;@Baal&gt; hello there[23:16] &lt;@arfer&gt; % return [regexp -nocase -- [subst -nocommands -nobackslashes {(\A|\s)${phrase}(\s|\Z)}] "I said Hello There to start the conversation"][23:16] &lt;@Baal&gt; 1</code></pre></div>For the most part a string match command would be used for such things but there are subtle differences.<br><br>A string match using the pattern "*${phrase}*" would return 1 for the text "I said hello therebye starting the conversation" whereas the above regular expression would return 0.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Tue Nov 09, 2010 7:42 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Elfriede]]></name></author>
		<updated>2011-01-01T05:24:28-04:00</updated>

		<published>2010-11-08T04:55:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95003#p95003</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95003#p95003"/>
		<title type="html"><![CDATA[[solved] regexp]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95003#p95003"><![CDATA[
Hi everyone <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>I need some kind of advice how to do the following:<br><br>I'd like to use like:<br><br>!regex search phrase -a=we -s=home or<br>!regex -a=we -s=home search phrase<br><br>Therefore i need a regex or an alternative to get it like<br>$var1 = search phrase<br>$var2 = home<br>$var3 = we<br><br>It should work in both cases, either the search phrase is at the beginning or at the end of the line. The search phrase can consist of one, two or more words.<br><br>I appreciate any kind of help! <br><br>thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9204">Elfriede</a> — Mon Nov 08, 2010 4:55 am</p><hr />
]]></content>
	</entry>
	</feed>
