Gammon Forum
Entire forum
MUSHclient
Plugins
Lua Plugin Help
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Calicoxx
(14 posts) bio
|
Date
| Sat 19 Sep 2009 03:51 PM (UTC) |
Message
| So I am trying to make a redirect trigger that when a certain event comes up, it redirects it to Gammon's Chat Redirector. I've added a few things specific to my MUD, but one that I can't seem to figure out goes something like this:
<trigger
enabled="y"
match="^[(.*?)\Bonus +(.*?)*$]"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>
I'm trying to match anything within the [ Bonus + ], but I believe I'm using the wrong character to signify the bonus obtained, or that the syntax in the match is messed up itself.
Any help would be greatly appreciated. | top |
|
Posted by
| Nick Gammon
Australia (22,973 posts) bio
Forum Administrator |
Date
| Reply #1 on Sun 20 Sep 2009 12:57 AM (UTC) |
Message
| Can you show an example line of what you are trying to match?
If you are trying to match something actually in square brackets you need to put a backslash in front of them.
eg. to match [Bonus] you would need to match on:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Twisol
USA (2,257 posts) bio
|
Date
| Reply #2 on Sun 20 Sep 2009 01:22 AM (UTC) |
Message
| Also, in your original example, '$]' probably isn't what you want; the $ is an end-of-line anchor. ']$' is what I expect you meant. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | top |
|
Posted by
| Calicoxx
(14 posts) bio
|
Date
| Reply #3 on Sun 20 Sep 2009 02:32 AM (UTC) |
Message
| I'm trying to match anything similar to "[PL Bonus +4]" | top |
|
Posted by
| Worstje
Netherlands (899 posts) bio
|
Date
| Reply #4 on Sun 20 Sep 2009 03:58 AM (UTC) |
Message
| Try: \[(.*?)Bonus \+(\d+)\]$ | top |
|
Posted by
| Calicoxx
(14 posts) bio
|
Date
| Reply #5 on Sun 20 Sep 2009 05:48 AM (UTC) |
Message
| I forgot to mention another one, which is [Exp Bonus], where exp can also be several other words. | top |
|
Posted by
| Worstje
Netherlands (899 posts) bio
|
Date
| Reply #6 on Sun 20 Sep 2009 08:26 AM (UTC) |
Message
| Then use the following regular expression: \[(.*?)Bonus(?: \+(\d+))?\]$ | top |
|
Posted by
| Twisol
USA (2,257 posts) bio
|
Date
| Reply #7 on Sun 20 Sep 2009 08:50 AM (UTC) |
Message
| I'd try this one instead, because I doubt he's interested in the space just before 'Bonus':
\[(?:(.*?) )Bonus(?: \+(\d+))?\]$
|
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | top |
|
Posted by
| Nick Gammon
Australia (22,973 posts) bio
Forum Administrator |
Date
| Reply #8 on Sun 20 Sep 2009 08:59 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.
|
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Worstje
Netherlands (899 posts) bio
|
Date
| Reply #9 on Sun 20 Sep 2009 01:39 PM (UTC) |
Message
|
Twisol said:
I'd try this one instead, because I doubt he's interested in the space just before 'Bonus':
\[(?:(.*?) )Bonus(?: \+(\d+))?\]$
I was feeling lazy and didn't want to unnecessarily make it more complicated since he presumably would try to take it apart. =p | top |
|
Posted by
| Calicoxx
(14 posts) bio
|
Date
| Reply #10 on Sun 20 Sep 2009 09:36 PM (UTC) |
Message
| Nah. The first one that was supplied worked, however, there is no plus in the matches for [Exp Bonus], so the plus sign should be omitted. I figured it would look like,
| 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.
27,161 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.