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.
 Entire forum ➜ MUSHclient ➜ General ➜ RegEx Trigger Matching Issue

RegEx Trigger Matching Issue

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


Posted by Copycatnebula   (6 posts)  Bio
Date Fri 10 Nov 2023 03:24 AM (UTC)

Amended on Fri 10 Nov 2023 03:25 AM (UTC) by Copycatnebula

Message
I have a variable in my script to easily change some regex matches.

<variable name="char_name">[a-zA-Z0-9 \-\,\.\']+</variable>


I use it in a trigger


 <trigger
   enabled="y"
   group="script-dpercent"
   keep_evaluating="y"
   expand_variables="y"
   match="^(?P&lt;tgt&gt;(@!char_name)) is (.+) on the (?P&lt;bpart&gt;.+) with your (?P&lt;type&gt;.+) causing (?P&lt;how_much&gt;.+) damage\.$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>trigger_style_runs = TriggerStyleRuns
   check_my_dmg("%0", "%&lt;tgt&gt;", "%&lt;bpart&gt;", "%&lt;type&gt;", "%&lt;how_much&gt;")
</send>
  </trigger>


The issue is the trigger is matching as follows (issue seems to be with the dash to me)
A dwarf guard is jabbed on the head with your pierce causing slight damage.
BUT NOT
A tough-looking dwarf guard is jabbed on the head with your pierce causing slight damage.

When i test this in a normal trigger vs a plugin using the following it works. Just not in the plugin script
^(?P<tgt>([a-zA-Z0-9 \-\,\.\']+)) is (.+) on the (?P<bpart>.+) with your (?P<type>.+) causing (?P<how_much>.+) damage\.$
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 11 Nov 2023 08:51 PM (UTC)
Message
I can't explain why it is doing it (your approach looks OK to me), however if you rejig the variable it works:



<variables>
  <variable name="char_name">[a-zA-Z0-9 ,.'-]+</variable>
</variables>


By putting the hyphen at the end of the regexp set it is not necessary to escape it.

- Nick Gammon

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

Posted by Copycatnebula   (6 posts)  Bio
Date Reply #2 on Mon 13 Nov 2023 03:53 AM (UTC)
Message
I will give that a try! 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.


2,689 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.