Page 1 of 1

I would like this trigger to fire more than once on a line

Posted: Thu Apr 16, 2015 10:19 pm
by Slayd
Here is a typical line:
[ 1173] bayberry bark [ 1471] bellwort flower [ 1615] black cohosh

Here is my pattern:
\[\s*(\d+)\]\s*(bayberry|bellwort|black cohosh|...|valerian)

I have selected Match all occurrences of the pattern in the line

I only get the first match in each line.

What am I doing wrong?

Re: I would like this trigger to fire more than once on a li

Posted: Thu Apr 16, 2015 11:10 pm
by Akaya
it matches the first occurrence you'll need to have it match 3 times from the line provided

Re: I would like this trigger to fire more than once on a li

Posted: Thu Apr 16, 2015 11:16 pm
by Slayd
Are you saying I need to expand the pattern 3 times?
or is there another way to get it to fire again. I thought that was what the Match all occurrences setting provided

Re: I would like this trigger to fire more than once on a li

Posted: Sat Apr 25, 2015 8:58 pm
by Vadi
Yeah match all captures all, but it doesn't re-run the code 3 times. That'd be inefficient. It goes once into the matches[] table, so iterate that accordingly.

Re: I would like this trigger to fire more than once on a li

Posted: Tue Jun 02, 2015 1:48 pm
by DarkArtist
I tested that pattern with match all ticked and got 3 matches back just fine.

I did
echo(matches[2]..'..'..matches[5]..'..'..matches[8])
and got
1173..1471..1615
I think you'd just have to test the matches to make sure they aren't nil and then put them in a table.

Re: I would like this trigger to fire more than once on a li

Posted: Tue Jun 02, 2015 5:01 pm
by Slayd
I ended up just have the match pattern include my pattern 3 times (with some '?' qualifiers on the latter patterns).

It never occurred to me to use the pattern once, tick match all, and then inspect the table for additional matches that I couldn't see explicitly in the pattern.

That's very useful. Who maintains the wiki? That would be a good example to have for match all.