It is now over 60 days since the last post. This thread is closed.
 
Refresh page
Posted by |
Ignis
(26 posts) bio
|
Date |
Sat 16 Nov 2013 07:15 PM (UTC) |
Message |
I'm trying to log something like the following to a file. however I never seem to get a successful match.
You examine a scroll carefully.
Object 'scroll' is type scroll, extra flags magic.
Weight is 1, value is 0.
Level 13 spells of: 'armor'.
the match I have is:
<triggers>
<trigger
enabled="y"
group="Multi Line"
ignore_case="y"
lines_to_match="6"
keep_evaluating="y"
match="You examine * carefully.\nObject '*' is type *, extra flags *.\n*\nHas * charges of level * '*'.\n"
multi_line="y"
regexp="y"
send_to="2"
sequence="100"
lowercase_wildcard="y"
>
<send>world.note "%2, kwds:%3, type %4, extras %5, %7 x lvl %8 %9"</send>
</trigger>
</triggers>
In the end I plan to do something more elaborate with the information I'm pulling, but having a hard time getting started retrieving said information. I also tried copying the above example of what i'm trying to match into test trigger and still no luck. Has anyone else had this trouble before? (Tried searching the forae and didn't seem to have any luck)
| top |
|
Posted by |
Nick Gammon
Australia (21,607 posts) bio
Forum Administrator |
Date |
Reply #1 on Sun 17 Nov 2013 10:09 AM (UTC) |
Message |
 |
Regular expressions
- Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
- Also see how Lua string matching patterns work, as documented on the Lua string.find page.
|
You probably mean:
Object '(.*)' is type (.*)
Wildcards work differently when you use regular expressions. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by |
Ignis
(26 posts) bio
|
Date |
Reply #2 on Tue 26 Nov 2013 06:14 AM (UTC) |
Message |
Ah, that helped greatly. I also learned a good deal about named wildcards
<triggers>
<trigger
enabled="y"
group="Multi Line"
lines_to_match="4"
keep_evaluating="y"
match="^You examine (?P<short>.+?) carefully\.$\n^Object (?P<key>.+) is type (?P<type>.+), extra flags (?P<flags>.+)\.$\n^Weight is (?P<weight>.+), value is (?P<gold>.+)\.$\n^Has (?P<charges>.+)\((.*)\) charges of level (?P<splvl>.+) (?P<spellname>.+)\.$"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
lowercase_wildcard="y"
>
<send>world.note "%<short>, kwds:%<key>, type %<type>, $%<gold>, %<charges> xlv %<splvl> %<spellname>"</send>
</trigger>
</triggers>
| 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.
3,617 views.
It is now over 60 days since the last post. This thread is closed.
 
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.