Page 1 of 1
echo all matches in line.
Posted: Fri Jan 29, 2010 2:28 pm
by Newbe
Hello.
I've got trigger with pattern:
. I wanted to echo all matches in line, so i tried echo(matches[1]), but it echoes only first sword in the line. I thought it worked recursivly and would echo all swords. In debug log first sword is stored in
and all others are kept in
Code: Select all
<regex mode: match all> capture groupe #0
. :'(
Hope you understood me and help me to solve the problem.
Re: echo all matches in line.
Posted: Fri Jan 29, 2010 2:38 pm
by sephiel
Not quite sure what you mean, but matches[1] is the whole line. So, if you have
^This is a thing I made up to test (\w+).$
then matches[1] is the whole line captured and matches[2] would be the wildcard in the brackets.
Hope that helps!
Re: echo all matches in line.
Posted: Fri Jan 29, 2010 2:45 pm
by Newbe
not really,
lets say a line like this comes:
Code: Select all
There is big sharp sword, red shiny sword and rusty broken sword.
then matches[1] would be "big sharp sword". I checked it in mud

Re: echo all matches in line.
Posted: Fri Jan 29, 2010 2:52 pm
by Heiko
No, matches[1] is the first *complete* match in the line. If you have 2 capture groups and chose the match all option and get a second match on the same line matches[] will look like this:
#1= first complete match
#2 = ---> first cap group of first match
#3 =---> second cap group of first match
#4 = second complete match
#5 = ---> first cap group of second match
#6 = ---> second cap group of second match
You can use display( matches ) to print the table matches to see what happens.
You can print all matches that you are interested in by iterating over the table matches.
This is being described in the manual.
Re: echo all matches in line.
Posted: Fri Jan 29, 2010 2:55 pm
by Newbe
Thanks for the info!
Now I can move on with my script
