Picking your name out of different spots in a list.

Post Reply
Tarrin
Posts: 6
Joined: Mon Nov 19, 2012 12:08 am

Picking your name out of different spots in a list.

Post by Tarrin » Thu Dec 13, 2012 9:36 am

This may be something basic, but I am completely new to Regex and have been learning slowly through making different GINA triggers. Something I am trying to do now if find a way to match your name out of a variety of spots in a list.

There are a few ATs in events where you can't use the trigger text specifically since its not aimed at *you*, but your name is listed in a generic other emote. Here is an example ( AT listed isn't an actual one, just something used for the sake of argument )

The giant throws a boulder at Person1, Person2, Person3!

A work around I currently use is making 2-3 different ATs, for different spots in the list ( first, second, and third ). It works for now. I figured there may be a way and I am just too inexperienced to figure it out.

Thanks in advance for any response!

Gimagukk
Site Admin
Posts: 237
Joined: Wed Oct 26, 2011 9:29 pm

Re: Picking your name out of different spots in a list.

Post by Gimagukk » Sat Dec 15, 2012 7:59 am

SOE likes to mix up how they list the three names in different scenarios (ie, sometimes it is "Player A, Player B, and Player C!" and other times it is "Player A, Player B and Player C!" without the second comma). For the scenario you listed, an easy start would be the following:

Code: Select all

The giant throws a boulder at .*{C}.*!
This is "good enough" for most cases, but will register false matches if you have two players named Jimbob and Jimbobby. The {C} tag is replaced with the name of the character being monitored by GINA before the string is passed through regex, so the above pattern becomes "The giant throws a boulder at .*Jimbob.*!". This means that Jimbobby will receive the alert every time Jimbob's name is called.

So, I usually get more specific and specific the characters which must be immediately before and after the character's name. In your scenario, there iis always a space right before the name and either a comma or an exclamation mark right after the name. So, we adjust the pattern like this:

Code: Select all

The giant throws a boulder at.*\s{C}[,!].*
The \s matches a whitespace character, and the [,!] matches any character in that set (ie, either "," or "!"). Note that there is no space between "at" and ".*" because if the player's name is first in the list, we need the \s for the match to be correct. If the sentence ends with period instead of an exclamation mark, the post-name match would be [,\.] -- making sure to quote the period so that it acts as a literal period instead of a "match any character" wildcard.

If the text we are trying to match does not have the second comma, it's just like the previous pattern, except that we have to add the \s tag as one of characters that we expect to see right after the {C} tag:

Code: Select all

The giant throws a boulder at.*\s{C}[\s,!].*
This last example would technically work in both scenarios (with or without a comma after the second name).

Post Reply