RegEx and Special Characters guide?

Have a question about how to use GINA? Ask away.
Post Reply
woot
Posts: 3
Joined: Wed Jan 25, 2017 1:03 am

RegEx and Special Characters guide?

Post by woot » Wed Jan 25, 2017 1:15 am

Hey there.

I'm a programmer and know RegEx in PHP decently enough to write some interesting RegEx, but I'm a bit tripped up on some of the syntax of the RegEx used in GINA. Is there a guide for RegEx syntax I can refer to?

As a base question for something I'm confused about, here's some regex I found on this board and modified:

Code: Select all

^((?:\w+\.)?\w+) (?:tells|told) you, '(?!Attacking (?<mob>.+) Master\.)
This is to detect when you receive a tell, but also filters out any tells you receive that look like:

Code: Select all

XXX tells you, 'Attacking MONSTER NAME Master.'
(filtering out tells from your pet)

I don't understand this syntax:

Code: Select all

(?:SOMETHING)
Why is there a colon there? Why is it not necessary when I use this

Code: Select all

(?<mob>.+)
to get the mob name? Also what exactly does

Code: Select all

<mob>.+
filter for? I understand the .+ filtering for any number of characters (or no characters), but what is the mob and why is the .+ necessary? I understand that

Code: Select all

(?!SOMETHING)
makes it not match when SOMETHING is there. Also I'm not sure why there's an escaped period here

Code: Select all

((?:\w+\.)?\w+)
and why there's a question mark before the second \w

Anyway, a more detailed RegEx syntax guide would be helpful.

Thanks!

HSishi
Posts: 62
Joined: Sun Aug 26, 2012 3:19 pm

Re: RegEx and Special Characters guide?

Post by HSishi » Wed Apr 05, 2017 1:35 pm

Hi Woot.

I dug up two links when I dived into GINA's RegEx feature:
http://www.regular-expressions.info/ - RegEx tutorial
http://regexr.com/ - RegEx testing site for playing around

The testing site also has an explain feature what every part of a given expression does.
You will also get a bubble info for each RegEx "command" you have in the whole expression line.

HowTo:
- Enter your expression at the top
- Go to the "Tools" grey bar and click "Explain". A nested block scheme comes up and explains every bit further.
In Texts area you can enter an example text, e.g. some log lines, and you will get highlighted every part which matches.

To your specific questions.
It would help if you had linked to the thread / posting where you found that trigger. Had to search for it ...

<mob> is a variable, like {S} or {S1} .. {S9}. It's just a handier name.

.+ or .* are, as you mentioned, a "ignore any number of characters" command. They will make GINA skip any amount of characters until the text after .+ or .* matches again.

The ?:SOMETHING parts are explained in this thread: viewtopic.php?f=7&t=142 .

Post Reply