Perl Regex Help Needed

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Perl Regex Help Needed

Post by noblestone »

mocci the Troll is a 46th level Lord Warrior, was born on 2012/06/29, and was last logged in on Thu Aug 15 18:40:26 2013.

Set as perl regex

Added:

(\w+) the (\w+) is a (\w+) level (\d+) (\w+), was born on (\d+) / (\d+) / (\d+), <--- on perl regex

send("b " .. matches[2] .. "the" .. matches[3] .. "is a" .. matches[4] .. "level" .. matches[5] .. "" .. matches[6] ..", was born on" .. matches[7] .. "/" .. matches[8] .. "/" .. matches[9])


The echo wont spit out the information, what were I missing here? Thanks for the help in advance.

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

Re: Perl Regex Help Needed

Post by phasma »

Try:

Code: Select all

(\w+) the (\w+) is a (\w+) level (\d+[st|nd|rd]) (\w+), was born on (\d+) / (\d+) / (\d+),
That will fix what you need to accomplish here, although if you want to actually properly capture the level, do take that into account.

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Perl Regex Help Needed

Post by Belgarath »

You're matching (\d+) with nothing in that regex where Lord would be... and the date /'s are spaced. Also if you want to echo the information, then make sure you change that send() to an echo() or cecho().

Code: Select all

Pattern: (\w+) the (\w+) is a (\d+[st|nd|rd|th]) level (.+), was born on (\d+)/(\d+)/(\d+)

And the echo...

echo("\nb "..maches[2].." the "..matches[3].." is a "..matches[4].." level "..matches[5]..", and was born on "..matches[6].."/"..matches[7].."/"..matches[8])
Last edited by Belgarath on Fri Aug 16, 2013 5:26 pm, edited 1 time in total.

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Perl Regex Help Needed

Post by noblestone »

Both of your suggestion haven't triggered anything, what I did was set up an trigger of anyone who types name.alt and it triggered my screen to enter name.alt to pull up the info. Hence another trigger, this one we are trying to solve.

send or echo wont work. Let me post snapshot here of what It looks like...

Image

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Perl Regex Help Needed

Post by Heiko »

Your regex pattern is wrong.
You can use the highlighter option to visualize your capture groups or display(matches) to print the matches table.
Start off simple.

mocci the Troll is a 46th level Lord Warrior, was born on 2012/06/29, and was last logged in on Thu Aug 15
(\w+) the (\w+) is a (.*) level (.*), was born on (.*), and was last logged in on (.*)
display(matches) now looks like this:
"mocci the Troll is a 46th level Lord Warrior, was born on 2012/06/29, and was
last logged in on Thu Aug 15 18:40:26 2013.",
"mocci",
"Troll",
"46th",
"Lord Warrior",
"2012/06/29",
"Thu Aug 15 18:40:26 2013."
}

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Perl Regex Help Needed

Post by noblestone »

Still wont fire.

I listed in my perl regex box as following:
(\w+) the (\w+) is a (.*) level (.*), was born on (.*), and was last logged in on (.*)
listed in box below as following:
send("b "..maches[2].." the "..matches[3].." is a "..matches[4].." level "..matches[5]..", and was born on "..matches[6]..", and was last logged in on"..matches[7])

Also tried this:
display(matches)

To no avial. Wondering why...

Thanks

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

Re: Perl Regex Help Needed

Post by Jor'Mox »

Well, just to be safe, put the display(matches) as the first line in the script (so it will happen even if there is an error somewhere else).

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: Perl Regex Help Needed

Post by Silvine »

Heiko's regex works fine for me. Make sure you have the pattern set as a regex expression not something else. It should look like this
Capture.PNG
Capture.PNG (16.64 KiB) Viewed 6885 times
and it give these results
results.PNG
results.PNG (8.61 KiB) Viewed 6885 times

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Perl Regex Help Needed

Post by noblestone »

Oh, I meant I wanted to report in our buddy chat channel.

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

Re: Perl Regex Help Needed

Post by Jor'Mox »

That is what the send line is supposed to do, yes?

Also, since you basically just want to send exactly what was matched, you can just use matches[1].

So, you could do this:

send("b " .. matches[1])

Post Reply