Regex issue matching.

AlterAeonUser
Posts: 26
Joined: Sun Sep 01, 2013 11:08 pm

Re: Regex issue matching.

Post by AlterAeonUser »

Except, it doesn't. All it does right now is highlight the captured matches. It will match/capture the first 3 lines, and show that in highlight.

So, the lines starting with Class, ---- and Mage get highlighted, but Cleric, Thief, Warrior and Necromancer, do not.

phasma
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm
Discord: phasma#4694

Re: Regex issue matching.

Post by phasma »

This is why you should not post at 6am. Sorry for that.

Personally, I would use this pattern. (Tested and confirmed working).

Code: Select all

^(\w+)\s+(\d+)\s+(\d+)\/\s?(\d+)\s+(\d+)\s+\(\s?(\d+)\%\)$

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Regex issue matching.

Post by Jor'Mox »

Wait... so the class line is getting highlighted? It doesn't come even close to matching the pattern we gave... so you are probably mistakenly using a multiline trigger. If you turn that off, and get rid of your other patterns, you will see that all of the different classes are correctly captured by the trigger pattern.

AlterAeonUser
Posts: 26
Joined: Sun Sep 01, 2013 11:08 pm

Re: Regex issue matching.

Post by AlterAeonUser »

Well, I was going to ask why a multiline trigger would be a mistake, but then I simply did what Jor'mox suggested and now it captures it all.. Weird to me. Thank you all for the assistance.

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Regex issue matching.

Post by Jor'Mox »

A multiline trigger is a trigger that fires one time after all of the listed patterns are matched within the set number of lines. A regular trigger fires for each line that matches the pattern, so in this case, it will fire for all of the lines you are interested in. A multiline trigger would need to have a pattern for each of them, even though those patterns would be the same. And it would only work so long as it had just the right number of classes to get information on.

AlterAeonUser
Posts: 26
Joined: Sun Sep 01, 2013 11:08 pm

Re: Regex issue matching.

Post by AlterAeonUser »

Ah, alright. Thank you Jor'Mox. Now, how do I get the trigger to capture and send the info to the script so I can make use of the info?

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Regex issue matching.

Post by Jor'Mox »

Do you have a separate script, or just a small script inside the trigger?
A script inside the trigger would be well suited to doing the same thing to each line, as soon as you see it. A separate script (which would require you to create a function inside a script that your trigger would use to send your script information) would be better suited to doing something with all of the information at once.

If you had a separate script, you could do something like this inside the trigger:
Code: [show] | [select all] lua
local class = matches[2]
local level = matches[3]
local micro = matches[4]
local micromax = matches[5]
local exp = matches[6]
local percent = matches[7]

storeClassInfo(class, level, micro, micromax, exp, percent)
And then something like this in a script to store everything:
Code: [show] | [select all] lua
local classInfo = {}

function storeClassInfo(class, level, micro, micromax, exp, percent)
   classInfo[class].level = level
   classInfo[class].micro = micro
   classInfo[class].micromax = micromax
   classInfo[class].exp = exp
   classInfo[class].percent = percent
end
Then you can make a second function to let you use the information that got stored in the classinfo table.

AlterAeonUser
Posts: 26
Joined: Sun Sep 01, 2013 11:08 pm

Re: Regex issue matching.

Post by AlterAeonUser »

Oh. Daunting to do a separate script for what basically will amount to using the info in a small trigger script. Thank you for the clarification. I see doing a script will be overkill for what I intend.

Post Reply