Trigger Regex Negation

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

Trigger Regex Negation

Post by solfeggio » Sat Jul 25, 2015 1:59 pm

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 » Sat Jul 25, 2015 11:24 pm

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 » Mon Aug 03, 2015 11:23 pm

^(.+) 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 » Tue Aug 04, 2015 12:13 am

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 » Tue Aug 04, 2015 4:55 am

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

Who is online

Users browsing this forum: No registered users and 2 guests