Page 1 of 1

Trigger Regex Negation

Posted: Sat Jul 25, 2015 1:59 pm
by solfeggio
Hello,

I am struggling to find the regex that I need for a particular trigger.

I would like the trigger to match any line showing that an NPC slashed another player, but not match lines showing that an NPC slashed me. So, for example:

Goblin slashes Tom's leg. (Match)
Goblin slashes Mary's leg. (Match)
Goblin slashes your leg. (No match)

I tried several variants of this:
Code: [show] | [select all] lua
^((.*) slashes !(your) (.*).)$
without success.

Any help appreciated.

Thanks.

Re: Trigger Regex Negation

Posted: Sat Jul 25, 2015 11:24 pm
by Nyyrazzilyss
Probably easiest would be something like

^.* slashes ([A-Za-z]+)'s leg.$

Re: Trigger Regex Negation

Posted: Mon Aug 03, 2015 11:23 pm
by EulersIdentity
^(.+) slashes (.+)\'?s? leg\.$

if you want to force it to be one word in each set of parentheses you can use:
^(\w+) slashes (\w+)\'?s? leg\.$

The previous poster's suggestion will fail in the 'your' example. You can make the apostraphe and s optional with '?'

Re: Trigger Regex Negation

Posted: Tue Aug 04, 2015 12:13 am
by Nyyrazzilyss
The 's isn't optional though: He wants the trigger to fail (no match) if that pattern is present.

Re: Trigger Regex Negation

Posted: Tue Aug 04, 2015 4:55 am
by EulersIdentity
Oh I totally misread that part. Yours is totally fine then, although the period at the end will allow matches of additional text at the end of the sentence. Bill murray's amazing dog slashes Cthulu's legz will also match.

^(\w+) slashes (\w+)\'s leg\.$ is sufficiently strict, and I think that ^([A-Za-z]+) slashes ([A-Za-z]+)\'s leg\.$ is the strictest you can go. I always forget that \w matches numbers!