Stuck in it badly

Posted by Nickpick on Sat 08 Apr 2006 06:37 PM — 6 posts, 24,209 views.

#0
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?
#1
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..
Australia Forum Administrator #2
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.
Australia Forum Administrator #3

(\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})
USA #4
Would...

^(You remove) (\d+) (goldenseal root, bringing the total in the Rift to) (\d+)\.$

...be just as fast?
Australia Forum Administrator #5
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.