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!
Picking your name out of different spots in a list.
Re: Picking your name out of different spots in a list.
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:
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:
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:
This last example would technically work in both scenarios (with or without a comma after the second name).
Code: Select all
The giant throws a boulder at .*{C}.*!
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}[,!].*
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,!].*