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

Post Reply
Slayd
Posts: 102
Joined: Mon Jul 25, 2011 4:57 am

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

Post 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?

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

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

Post by Akaya »

it matches the first occurrence you'll need to have it match 3 times from the line provided

Slayd
Posts: 102
Joined: Mon Jul 25, 2011 4:57 am

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

Post 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

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

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

Post 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.

DarkArtist
Posts: 21
Joined: Sun Dec 15, 2013 12:36 am

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

Post 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.

Slayd
Posts: 102
Joined: Mon Jul 25, 2011 4:57 am

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

Post 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.

Post Reply