Wildcard Triggers

Posted by C on Mon 21 Jan 2002 08:37 PM — 6 posts, 20,700 views.

#0
Hey,

I want a Trigger that acts on the expression:

JohnDoe tells the group (in common), 'mana'.

Sends: Cast 'give mana' JohnDoe.

I have the following Trigger:
^(\w*) tells the group (in common), 'mana'.*$
To send: cast 'give mana' %1

But it doesn't seem to work, any ideas what I am doing wrong? Any help would be much appreciated :)

Thanks
Australia Forum Administrator #1
I presume you have checked the "regular expression" box, because you are using "^(\w*)" in the trigger.

In that case, special characters need to be "escaped" or they won't work as you expect. For instance "." is a wildcard, and "( and ")" have special meaning.

Try:


^(\w*) tells the group \(in common\)\, \'mana\'$


You can simplify the process of using regular expressions by entering a simple expression and then clicking the "Convert to Regular Expression" box. That will automatically do the escaping for you. eg.

Enter:


* tells the group (in common), 'mana'


After clicking "Convert to Reg. Exp." you will get:


^(.*?) tells the group \(in common\)\, \'mana\'$


Then you can amend it if you want, for instance by changing ".*" to "\w*".



#2
Thanks Nick,

I tried changing the trigger so it reads:

^(\w*) tells the group \(in common\)\, \'mana\'$

with regular expression ticked. It is set to send:

cast 'give mana' %1

That didn't seem to work for me so I tried to convert it to a regular expression like you showed and sure enough I got:

^(.*?) tells the group \(in common\)\, \'mana\'$

changing the .* to \w, the only difference being the ? instead of * after the \w. The same things are ticked (Regular expression) but again it didn't return anything when I fed the line:

Blah tells the group (in common), 'mana'.

into the client. Sniffle, I'm not sure where to go from here, am I a lost cause? :P

Thanks,

C
Canada #3
Am I the only one noticing the extra . at the end of the output line, that is not being looked for on the trigger line?

(An extra \. before the $)
Australia Forum Administrator #4
You are right. When I looked at the regexp I saw ".*" which I assumed was a wildcard match.

If you want the regexp to match on a dot you need to put \. in it, as Magnum said.


Quote:

Sniffle, I'm not sure where to go from here, am I a lost cause? :P


No, they can be made to work. :) Set the trigger to colour the line, so at least you can confirm when it matches. Then get the response right.

#5
Hey again,

Thanks very much for your help all! In the end my trigger looked like this:

^(\w*) tells the group \(in common\)\, \'mana\'\.*

Set to send:
cast 'give mana' %1

It works very nicely now ;)

Thanks again for your help,

C