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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  RegEx Trigger Matching Issue

RegEx Trigger Matching Issue

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


Posted by Copycatnebula   (5 posts)  [Biography] 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\.$
[Go to top] top

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

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


1,657 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 HostDash]