regexp lastmatch with brackets

All about the macro plugin can be found in this forum. This forum is intended for the macro plugin only.

Moderator: Moderators

ptcarino
Plain Yogurt
Plain Yogurt
Posts: 62
Joined: 17 Jul 2010, 00:48
Noob?: No
Location: pRO Valkyrie

regexp lastmatch with brackets

#1 Post by ptcarino »

i'm using this macro event

Code: Select all

console /\[dist=(.*)\] (.*) \((\d+)\): (.*)(Flag)(.*)$/i
my problem is if i try to get the lastmatch for names and the name has brackets, it ignores the brackets and just gives out the rest.

for example:
character [FS] blahblah triggered the macro.
the bot is programmed to do like this

Code: Select all

do c hello $name
what happens is actually like this
ImABot: hello blahblah
instead of
ImABot: hello [FS] blahblah
i run the bot buffers for my guild and i want my buffers to all buff the same person. my solution to that is for them to rely on another bot that tells them their target and all i could think of a trigger is this (through party/guild chat). the code for the buffers would be simplier too cause all i need for them is just "do sp ## @player ($name)" and no more eval guild checks and less IF statements.

seems i've hit a wall with this one. any help would be appreciated.
Image
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: regexp lastmatch with brackets

#2 Post by EternalHarvest »

ptcarino wrote:

Code: Select all

console /\[dist=(.*)\] (.*) \((\d+)\): (.*)(Flag)(.*)$/i
Use non-greedy variant of "*" quantifier for matching distance, or specify more narrow character class there. By default all matching is "greedy".
http://perldoc.perl.org/perlre.html#Quantifiers
ever_boy_
Developers
Developers
Posts: 308
Joined: 06 Jul 2012, 13:44
Noob?: No

Re: regexp lastmatch with brackets

#3 Post by ever_boy_ »

$.lastpub ?
ptcarino
Plain Yogurt
Plain Yogurt
Posts: 62
Joined: 17 Jul 2010, 00:48
Noob?: No
Location: pRO Valkyrie

Re: regexp lastmatch with brackets

#4 Post by ptcarino »

thanks for the replies. im currently studying quantifiers and i'll give $.lastpub a try.

thanks for the link EternalHarvest.
Image
ptcarino
Plain Yogurt
Plain Yogurt
Posts: 62
Joined: 17 Jul 2010, 00:48
Noob?: No
Location: pRO Valkyrie

Re: regexp lastmatch with brackets

#5 Post by ptcarino »

EternalHarvest wrote:
ptcarino wrote:

Code: Select all

console /\[dist=(.*)\] (.*) \((\d+)\): (.*)(Flag)(.*)$/i
Use non-greedy variant of "*" quantifier for matching distance, or specify more narrow character class there. By default all matching is "greedy".
http://perldoc.perl.org/perlre.html#Quantifiers
non-greedy quantifier worked. thanks!
Image