Trigger/Reg expression question

Posted by Sekel on Sun 16 Jun 2002 05:47 PM — 4 posts, 15,051 views.

#0
Hello All! I am pretty green to this stuff but I have a question that I haven't been able to figure out. I am trying to make an attack trigger:

^(.*) attacks (.*)
kill %2

The problem is that the period at the end of line is getting passed:

Joe attacks Foo.
attack Foo.
No such thing as Foo.

I can't figure out how to make it not read the "." at the end of line. Does anyone have any ideas?

Thanks!

Chris
USA #1
Well the problem is that . and * are both special characters, so you need to do the following:

^(.*) attacks (.*)\.

This should match anything with that pattern that 'ends in' a period. If there are times it won't you might need to add a set of '[]' around the '\.'. ;) As is always the case there are half a dozen ways to do it with regex depending on how accurate you need to be. lol

------------
Grasshopper: 'I have a problem I want to solve with regular expressions'
Master: 'Now you have two problems'
#2
Thank you for the help. I tried that, with and without the brackets and it won't work. When it passes %2 I no longer see the period, however, I still get the following:

Joe attacks Artificer.
kill Artificer
You see no such thing to kill here.

I wonder if it is passing some kind of hidden character? Any clues?

Thanks again!

Chris
USA #3
Hmm.. I would say that the mud is expecting to recieve a lowercase verion and the trigger retrieves an uppercase one. i.e.:

mud expects> artificer
you're giving it> Artificer

No easy way to fix this unless you move the send text to a script like the following:
sub attackit(trigname, output, wildcards)
  world.send "kill " & lcase(wildcards(2))
end sub

I don't believe there is any other way to fix the uppercase letter in there and that 'looks' like the most likely problem.