Regular Expressions

Posted by Toruk on Tue 22 Apr 2008 12:23 PM — 3 posts, 16,590 views.

#0
Can Anyone explain to me what I'm doing wrong on this expression

I want it to send a page to me if someone else other then Jordan sends me a tell..

If I take out (?!Jordan ) the expression works fine.
And Yes i know its matching my prompt. I cant get it to work with out having it match my Prompt. ^ wouldnt work at all. But it's fine that it matches my prompt because I only want this trigger to run when im crafting and I will have full health when Im crafting.

<triggers>
<trigger
enabled="y"
match="698H 717M 947S &gt; (?!Jordan ) (\w*) (gossips|say|states|tells you)\, '(.*?)$"
regexp="y"
sequence="100"
>
<send>Page Joe
</send>
</trigger>
</triggers>

Heres a line from the game


698H 717M 947S > Jordan tells you, 'I'll give you 50000 coins for that'
Amended on Tue 22 Apr 2008 12:30 PM by Toruk
Australia Forum Administrator #1
Check out this page for a description of how to do exactly that:

http://www.gammon.com.au/regexp

Scroll down to where it says "Negative lookbehind assertions".

The example given there is similar to what you are doing. With a bit of re-arranging it works fine:


<triggers>
  <trigger
   enabled="y"
   match="698H 717M 947S &gt; (\w+)(?&lt;!Jordan) (gossips|say|states|tells you)\, '(.*?)$"
   regexp="y"
   sequence="100"
  >
  <send>Page Joe
</send>
  </trigger>
</triggers>



However you should be able to get rid of the prompt numbers. Won't that be a hassle when your max health changes?

Just replace each of the numbers with \d+ - that means one or more digits. Then it will match on any numbers.


<triggers>
  <trigger
   enabled="y"
   match="\d+H \d+M \d+S &gt; (\w+)(?&lt;!Jordan) (gossips|say|states|tells you)\, '(.*?)$"
   regexp="y"
   sequence="100"
  >
  <send>Page Joe
</send>
  </trigger>
</triggers>

Amended on Tue 22 Apr 2008 09:15 PM by Nick Gammon
#2
Ah works like a charm

and thanks for the page on regexp I think it will help alot more then what i seen under scripting.