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.
 Entire forum ➜ MUSHclient ➜ Bug reports ➜ Multiple line triggers

Multiple line triggers

Posting of new messages is disabled at present.

Refresh page


Posted by Norbert   USA  (61 posts)  Bio
Date Sun 12 Sep 2004 07:43 AM (UTC)

Amended on Sun 12 Sep 2004 02:48 PM (UTC) by Norbert

Message
When I test this trigger with trace on, it shows that it matches, it also matches again on each of the next 2 lines that appear in the output window. So the trigger matches an extra 2 times when tested.


<triggers>
  <trigger
   enabled="y"
   lines_to_match="11"
   match="^You are (.*?) \((.*?)\)\,\nPlayer level (.*?)\, barbarian level (.*?)\.\nYou have (.*?) player experience\, (.*?) tribe exp\.\n(.*?)\/(.*?) hit points \((.*?)\/(.*?) spell points\)\, (.*?)\/(.*?) quest points\,\n(.*?) Strength\, (.*?) Dexterity\, (.*?) Constitution\, and (.*?) gold coins\.\nYou have (.*?) experience you can make into (.*?) tribe experience\.\nYou are (.*?)\.\n(?:Wimpy .*?\n|)(?:You are in barbarian weaponless combat mode\.\n|)You are (.*?)\.\nage\: (?: (\d+) day(?:s|)|)(?: (\d+) hour(?:s|)|)(?: (\d+) minute(?:s|)|)(?: (\d+) second(?:s|)|)\.$"
   multi_line="y"
   name="barbtrig"
   regexp="y"
   send_to="10"
   sequence="100"
  >
  <send>/world.note &quot;barb&quot;</send>
  </trigger>
</triggers>




You are Joe the Elder of the Haraku (crusader),
Player level E8, barbarian level 20.
You have 27,858,768 player experience, 1,857,268 tribe exp.
301/301 hit points (69/69 spell points), 408/450 quest points,
22 Strength, 21 Dexterity, 21 Constitution, and 121,954 gold coins.
You have 2,100,707 experience you can make into 105,035 tribe experience.
You are in a drunken stupor.
Wimpy mode.  You should be ashamed.
You are in barbarian weaponless combat mode.
You are somewhat tired.
age:  8 days 7 hours 32 minutes 23 seconds.


I'm not sure if this is a bug or not, but what I was thinking that maybe causing the problem was that 2 of the \n are enclosed in parenthses. Maybe they are hidden from mushclient and muschlient thinks it only got 9 lines when it really got 11 lines. Hence matching on the very next 2 lines. The reason for (?:Wimpy .*?\n|)(?:You are in barbarian weaponless combat mode\.\n|) is because those lines are not always there.

Norbert

-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 13 Sep 2004 08:36 AM (UTC)
Message
I can't reproduce that. In my test it only matches once. Perhaps paste the "next 2 lines" or whatever makes it match for you.

- Nick Gammon

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

Posted by Norbert   USA  (61 posts)  Bio
Date Reply #2 on Mon 13 Sep 2004 05:54 PM (UTC)
Message
Sorry about that I forgot to change the what it matches on. It does it when the wimpy or combat mode is turned off, so the data it's matching on would look like this below. I'm really not sure it's a bug, the trigger is set to 11 lines to match, but it's not always going to get 11 lines since wimpy and combat mode are not always turned on.



You are Joe the Elder of the Haraku (crusader),
Player level E8, barbarian level 20.
You have 27,858,768 player experience, 1,857,268 tribe exp.
301/301 hit points (69/69 spell points), 408/450 quest points,
22 Strength, 21 Dexterity, 21 Constitution, and 121,954 gold coins.
You have 2,100,707 experience you can make into 105,035 tribe experience.
You are in a drunken stupor.
You are somewhat tired.
age:  8 days 7 hours 32 minutes 23 seconds.

Norbert

-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #3 on Tue 14 Sep 2004 01:04 AM (UTC)
Message
OK, the solution is simple. It's not a bug. :)

It is correctly detecting that the text you want to match is somewhere in the last 11 lines, even if the text is only 9 lines long.

What you need to do is add \Z to the end, just before the $.

I won't reproduce the whole thing, but it will look like this:


^You are (blah blah) \.\Z$


If you look at the regular expression documentation it says that:


  \Z     matches at end of subject or before newline at end


This is the important thing, "at end of subject". In other words it will only match when your regular expression is at the *end* of the text. So, if extra lines appear, it is no longer at the end, so it doesn't match any more.

- Nick Gammon

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

Posted by Norbert   USA  (61 posts)  Bio
Date Reply #4 on Wed 15 Sep 2004 01:46 AM (UTC)
Message
Thank you very much, that fixed the problem.

I was using the Regular expression syntax link (http://www.gammon.com.au/mushclient/regexp.htm) to help me make the trigger and \Z is not on that page, but I did find it in the mushclient help after I read your post.

Norbert

-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
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.


16,416 views.

Posting of new messages is disabled at present.

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.