Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Trigger/Reg expression question

Trigger/Reg expression question

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Sekel   (3 posts)  Bio
Date Sun 16 Jun 2002 05:47 PM (UTC)
Message
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
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #1 on Sun 16 Jun 2002 06:45 PM (UTC)
Message
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'
Top

Posted by Sekel   (3 posts)  Bio
Date Reply #2 on Sun 16 Jun 2002 07:00 PM (UTC)
Message
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
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #3 on Sun 16 Jun 2002 08:10 PM (UTC)
Message
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.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,261 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.