Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ VBscript ➜ Reg Exp

Reg Exp

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Hoss   USA  (48 posts)  Bio
Date Wed 23 Jul 2008 06:25 PM (UTC)
Message
So I'm trying to create a reg exp trigger to match on:

          vial84905 the venom colocasia (pinewood vial)              1   1000gp


What I have is:

 ^[ ]+vial(\d) the venom (\w) (pinewood vial)[ ]+(\d)[ ]+(\d)gp$ 


For some reason it is not matching and I'm running out of ideas. Any help will be apprecited.


Thanks

Hoss

Top

Posted by Darwin   USA  (125 posts)  Bio
Date Reply #1 on Thu 24 Jul 2008 01:32 AM (UTC)
Message
Try this:
^\s+vial(\d+) the venom (\w+) (pinewood vial)\s+(\d*+)\s+(\d*+)gp$


Your match isn't working because the "\d" and "\w" is only looking for 1 character and by your text to match you will need to match more (hence the +). Also, spaces can be matched using "\s" although a set "[ ]" will work just as well.
Top

Posted by Hoss   USA  (48 posts)  Bio
Date Reply #2 on Thu 24 Jul 2008 01:59 AM (UTC)
Message
Hmm I just tried that but it is not matching on the line still.

Any other ideas?


Thanks

Hoss
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 24 Jul 2008 11:34 PM (UTC)
Message
To actually match brackets you need to put a backslash in front of them, because brackets in a regexp mean "capture the thing inside".

Also "(\d*+)" is not quite right, it should be "(\d+)" .

The trigger below matched for me on your test string:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="^\s+vial(\d+) the venom (\w+) \(pinewood vial\)\s+(\d+)\s+(\d+)gp$"
   regexp="y"
   sequence="100"
  >
  </trigger>
</triggers>



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hoss   USA  (48 posts)  Bio
Date Reply #4 on Thu 24 Jul 2008 11:38 PM (UTC)
Message
Thanks Nick that works perfectly.


Nathan
Top

Posted by Hoss   USA  (48 posts)  Bio
Date Reply #5 on Sat 26 Jul 2008 05:16 PM (UTC)

Amended on Sat 26 Jul 2008 05:19 PM (UTC) by Hoss

Message
Alright so I have the first trigger set up and working perfectly but I have a new line I need to match.

A canvas backpack, #11580.


It must also match on

A pair of exquisite knee-high tanned doeskin boots lined with fine lamb's wool, #204952.


and on

An oaken vial, #51978.


Here is what I have so far:

^(A|An) (\.+)\, #(\d+)\.$


Any help would be appreciated

Thanks
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #6 on Sat 26 Jul 2008 07:28 PM (UTC)
Message
This:
(\.+)

should probably be this:

(.+)

because you want to match on any character, not just periods.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Hoss   USA  (48 posts)  Bio
Date Reply #7 on Sun 27 Jul 2008 03:45 PM (UTC)
Message
Thanks David that fixed the problem.




Hoss
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.


20,575 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.