[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  double send on regular expression match
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

double send on regular expression match

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


Posted by Essidus   (16 posts)  [Biography] 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?
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] 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
[Go to top] top

Posted by Essidus   (16 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,405 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,405 posts)  [Biography] 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
[Go to top] top

Posted by Essidus   (16 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,405 posts)  [Biography] 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
[Go to top] top

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


4,274 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]