Reg Exp

Posted by Hoss on Wed 23 Jul 2008 06:25 PM — 8 posts, 29,252 views.

USA #0
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

USA #1
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.
USA #2
Hmm I just tried that but it is not matching on the line still.

Any other ideas?


Thanks

Hoss
Australia Forum Administrator #3
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>


USA #4
Thanks Nick that works perfectly.


Nathan
USA #5
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
Amended on Sat 26 Jul 2008 05:19 PM by Hoss
USA #6
This:
(\.+)

should probably be this:

(.+)

because you want to match on any character, not just periods.
USA #7
Thanks David that fixed the problem.




Hoss