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 ➜ double send on regular expression match

double send on regular expression match

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


Posted by Essidus   (16 posts)  Bio
Date Sun 05 Feb 2006 08:04 PM (UTC)
Message
On a regular expression trigger I use that gets fired on my mu*'s system messages as thus:
\n          [\*\*\*\*\*\*\*\*\*\*\*\*\-\-Rumour Monger\-\-\*\*\*\*\*\*\*\*\*\*\*\*]\n(.*)\n          [\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*]\n\Z


and sends a simple note

note "trigger matched, %1 as wildcard"


has been doubling. I've checked the trigger info, and it seems to fire twice every time it matches. Anyone have a solution for me?
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #1 on Mon 06 Feb 2006 08:56 AM (UTC)
Message
It's surprising that it matches at all, since technically it shouldn't. Are you sure that there are no other triggers that could be matching that output? Because I really don't see how that regular expression could match what you seem to be trying to match. It should match on stuff like:


        *
Blah
        *


or


        R
Blah
        *


Since you have two character classes in there, each matching exactly one character.

In any case, try the following pattern instead, it seems to match without any surprises and is considerably faster:

\n          \*{12}\-\-Rumour Monger\-\-\*{12}\n(.*)\n          \*{41}\n\Z
Top

Posted by Essidus   (16 posts)  Bio
Date Reply #2 on Mon 06 Feb 2006 01:54 PM (UTC)
Message
There were a couple of brackets missing on your version of the string, but no matter. More importantly, I got the same effect as before. The trigger itself is listing as being matched twice for every group matched, so that the results come out like this:


          [************--Rumour Monger--************]
           Player arrives in Game.
          [*****************************************]
Script triggered.            Player arrives in Game. returned
Script triggered.            Player arrives in Game. returned


Now, just like last time, in the trigger information itself, it's saying it's getting called twice.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 06 Feb 2006 08:15 PM (UTC)
Message
How many lines have you set the trigger to match on?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #4 on Tue 07 Feb 2006 12:49 AM (UTC)
Message
Quote:

[\*\*\*\*\*\*\*\*\*\*\*\*\-\-Rumour Monger\-\-\*\*\*\*\*\*\*\*\*\*\*\*]


Apart from being tedious, this just looks wrong. You haven't escaped the bracket on the left or right, so you really matching on a "set" of characters, consisting of asterisks, any of the letters in "Rumour Monger" and so on.

The middle bit (I haven't counted the spaces) should look like this:


\[\*{12}\-{2}Rumour Monger\-{2}\*\{12}\]


Note the backslash before the square brackets.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Essidus   (16 posts)  Bio
Date Reply #5 on Tue 07 Feb 2006 02:49 AM (UTC)
Message
Right, I'm using the changed code now, but it still gets doubled triggers, as if the trigger gets called twice, which is proven correct in the trigger edit window's call # (It goes up by two with every one match). There is only one call, and it matches five lines, those five being two blank lines, and the three with characters in them.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Tue 07 Feb 2006 04:34 AM (UTC)
Message
OK, I see what you mean. You actually had the backslashes there, they just didn't show up in the forum posting. You need to "quote forum codes" when posting stuff with square brackets in it, there is a function in the MUSHclient notepad to do that.

I fixed the problem by adding \A to the very start of the regular expression. I think the problem is that you are matching 3 lines in the regular expression, but taking 5 lines in your trigger. Thus there is the potential for the match to occur twice.

Either cut down the match count to 3, or actually put the blank lines into the regexp.

The \A that I put in says "match start of subject" so that is an assertion that the trigger is the start of the subject (that is, the start of the 5 lines).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Essidus   (16 posts)  Bio
Date Reply #7 on Tue 07 Feb 2006 06:03 PM (UTC)
Message
That worked perfectly! Thank you.
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.


20,396 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.