Trigger Regex Negation

Post Reply
solfeggio
Posts: 4
Joined: Wed Apr 08, 2015 9:18 pm

Trigger Regex Negation

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

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Trigger Regex Negation

Post by Nyyrazzilyss »

Probably easiest would be something like

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

EulersIdentity
Posts: 27
Joined: Fri Jun 26, 2015 8:52 am

Re: Trigger Regex Negation

Post 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 '?'

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Trigger Regex Negation

Post by Nyyrazzilyss »

The 's isn't optional though: He wants the trigger to fail (no match) if that pattern is present.

EulersIdentity
Posts: 27
Joined: Fri Jun 26, 2015 8:52 am

Re: Trigger Regex Negation

Post 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!

Post Reply