Gammon Forum
Entire forum
MUSHclient
General
RegEx Trigger Matching Issue
RegEx Trigger Matching Issue
|
You need to log onto the forum to reply or create new threads.
 
Refresh page
Posted by
| Copycatnebula
(5 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<tgt>(@!char_name)) is (.+) on the (?P<bpart>.+) with your (?P<type>.+) causing (?P<how_much>.+) damage\.$"
omit_from_output="y"
regexp="y"
send_to="14"
sequence="100"
>
<send>trigger_style_runs = TriggerStyleRuns
check_my_dmg("%0", "%<tgt>", "%<bpart>", "%<type>", "%<how_much>")
</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 (22,926 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 |
|
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.
296 views.
You need to log onto the forum to reply or create new threads.
 
Refresh page
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.