Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Nickpick
(24 posts) bio
|
| Date |
Sat 08 Apr 2006 06:37 PM (UTC) [ quote
] |
| Message |
I've got a problem! Again!
I've got this piece of script, which works in the IMMEDIATE mode, but refuses to work while put into a trigger:
///
set re = new regexp
stringe = "You remove 1 goldenseal root, bringing the total in the Rift to 38."
With re
.Pattern = "^(You remove) (\d|\d\d|\d\d\d|\d\d\d\d) (goldenseal root, bringing the total in the Rift to) (\d|\d\d|\d\d\d|\d\d\d\d)(.)$"
.IgnoreCase = False
.Global = False
End With
ma = re.test(stringe)
world.note ma
world.enabletrigger "GoldensealOUTR", "true"
///
Basically it's supposed to give out -1 and it does, in immediate mode. However, once I insert it into a trigger and make it fire, it gives out 0. Help? | top |
|
| Posted by |
Nickpick
(24 posts) bio
|
| Date |
Reply #1 on Sat 08 Apr 2006 07:18 PM (UTC) [ quote
] |
| Message |
Issue solved. Incredibly bizarre nevertheless.
///
set re = new regexp
stringe = "%1"
With re
.Pattern = "^(You remove) ([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]) (goldenseal root, bringing the total in the Rift to) ([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9])(.)$"
.IgnoreCase = False
.Global = False
End With
ma = re.test(stringe)
world.note ma
world.enabletrigger "GoldensealOUTR", "true"
///
Just had to replace \d with [0-9]. Funnily enough \d still worked in the IMMEDIATE. Oh well.. | top |
|
| Posted by |
Nick Gammon
Australia (18,772 posts) bio
Forum Administrator |
| Date |
Reply #2 on Sun 09 Apr 2006 04:14 AM (UTC) [ quote
] |
| Message |
| I think in the trigger window, MUSHclient processes sequences like \n to be newlines, so your solution would have been to make \d into \\d in that case. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
Nick Gammon
Australia (18,772 posts) bio
Forum Administrator |
| Date |
Reply #3 on Tue 13 Jun 2006 09:31 PM (UTC) [ quote
] |
| Message |
(\d|\d\d|\d\d\d|\d\d\d\d)
...
([0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9])
Both of these can be simplified by using the "count" syntax:
(\d{1,4})
...
([0-9]{1,4})
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
NeoFryBoy
USA (42 posts) bio
|
| Date |
Reply #4 on Tue 04 Jul 2006 08:50 AM (UTC) [ quote
] |
| Message |
Would...
^(You remove) (\d+) (goldenseal root, bringing the total in the Rift to) (\d+)\.$
...be just as fast? | top |
|
| Posted by |
Nick Gammon
Australia (18,772 posts) bio
Forum Administrator |
| Date |
Reply #5 on Tue 04 Jul 2006 09:42 PM (UTC) [ quote
] |
| Message |
| They would both be fast enough, the original one matches on 1-4 digits, yours would match on 1 to any number. Unless there was some obscure problem with mismatches (eg. with a 5 digit number) your solution is probably more elegant. |
- 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.
2,521 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )