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 ➜ Regular expression help

Regular expression help

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


Posted by Arundor   (2 posts)  Bio
Date Wed 21 Jun 2006 11:15 PM (UTC)
Message
I'm trying to match this line:

You take a drink from * vial.


But only if it is NOT followed by one of these lines:

The potion heals and soothes you.
Ah, the soothing bromides help strengthen your ego.
Your mind feels stronger and more alert.


I'm trying to use this trigger:

<trigger
   enabled="y"
   lines_to_match="2"
   match="(You take a drink from (.*) vial\.\n)(?!((The potion heals and soothes you\.)|(Ah, the soothing bromides help strengthen your ego\.)|(Your mind feels stronger and more alert\.)))"
   multi_line="y"
   regexp="y"
   send_to="2"
   sequence="100"
  >
  <send>Matched.</send>
</trigger>


But it isn't working out. It matches "You take a drink from * vial." no matter what line comes after it. Any suggestions?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 21 Jun 2006 11:38 PM (UTC)
Message
You need to anchor to the start of the subject. Otherwise 2 lines like this cause it to match:


The sun rises.
You take a drink from the blue vial.


That is 2 lines, and after "you take a drink" is NOT the lines you wanted, so it matches. However by anchoring to the start of the subject, you force it to consider "you take a drink" as the start of the two lines.

This worked for me:


<triggers>
  <trigger
   enabled="y"
   lines_to_match="2"
   match="\A(You take a drink from (.*) vial\.\n)(?!((The potion heals and soothes you\.)|(Ah, the soothing bromides help strengthen your ego\.)|(Your mind feels stronger and more alert\.)))"
   multi_line="y"
   regexp="y"
   send_to="2"
   sequence="100"
  >
  <send>Matched.</send>
  </trigger>
</triggers>

- Nick Gammon

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

Posted by Arundor   (2 posts)  Bio
Date Reply #2 on Wed 21 Jun 2006 11:44 PM (UTC)
Message
Makes sense. 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.


11,505 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.