RegEx Trigger Matching Issue

Posted by Copycatnebula on Fri 10 Nov 2023 03:24 AM — 3 posts, 7,758 views.

#0
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\.$
Amended on Fri 10 Nov 2023 03:25 AM by Copycatnebula
Australia Forum Administrator #1
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.
#2
I will give that a try! Thank you